自XCode最新更新后,以下两行代码出现编译错误。任何人都可以建议我进行调整以使程序再次编译和运行吗?
var sceneData = NSData.dataWithContentsOfFile(path, options: .DataReadingMappedIfSafe, error: nil)
var archiver = NSKeyedUnarchiver(forReadingWithData: sceneData) archiver.setClass(self.classForKeyedUnarchiver(), forClassName: "SKScene")
如有任何帮助,我们将不胜感激。
最佳答案
您可以使用(iOS < 8.0)
NSData.dataWithContentsOfMappedFile(path)
或(iOS >= 7.0)
var sceneData = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: nil)
如果您在 XCode 6.1 中创建一个新的 SpriteKit 示例项目,您将看到更改。
关于ios - SWIFT 代码 dataWithContentsOfFile 因更新到 XCode 6.1 而损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26605425/