我刚刚完成了我的swift应用程序的最后几次修改。但是在升级到Beta 7之后,它给了我“ContentOfFile”字符串的错误。有人能帮我理解我该如何解决这个问题吗?
这是我的自动取款机。
//Reads the Text File
if var path = NSBundle.mainBundle().pathForResource("Chapters", ofType: "txt"){
//Reads the Text File into one Huge String
var data = String(contentsOfFile:path, encoding: NSUTF8StringEncoding, error: nil)
//sets String content of the Text File as an Array. With each string start at \n (new line)
if var content = (data){
//from the mass string of data from the text file, Each chapter content is seperated by #
var Chapters: [String] = content.componentsSeparatedByString("@")
//without removing index in the beginning there will be an extra element printed in the array.
Chapters.removeAtIndex(0)
错误消息:
无法使用类型“(contentsOfFile:String,编码:UInt,错误:NilLiteralConvertible)”的参数列表调用类型“String”的初始值设定项