我无法从Swift中的.text文件中读取文本字符串.
我可以使用以下代码管理文件
var writeError: NSError?
let theFileToBeWritten = theStringWillBeSaved.writeToFile(pathToTheFile, atomically: true, encoding: NSUTF8StringEncoding, error: &writeError);
Run Code Online (Sandbox Code Playgroud)
但每当我尝试使用"String.stringWithContentsOfFile"读取文件时,我得到"'String.Type'没有名为'stringWithContentsOfFile'的成员".stringWithContentsOfFile也不会出现在自动完成中.
我正在使用Xcode 6.1 GM Seed 2.
我见过人们使用"stringWithContentsOfFile"在许多教程和堆栈溢出中从文件中读取文本,但为什么它对我不起作用?
我刚刚下载了Xcode6-beta6.对于以下代码,我收到编译器错误"模糊使用运算符'>'"
reversed = sorted(names, { s1, s2 in s1 > s2 } )
它之前在Xcode6-beta5中运行.
有任何想法吗?