升级到 xCode6.1 后,我无法编译我上次正常的项目。我从未改变过这个文件中的任何内容。请帮帮我!!!
AppDelegate.swift:75:29:
errorWithDomain(_:code:userInfo:)' is unavailable: use object construction 'NSError(domain:code:userInfo:)
lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = {
// The persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail.
// Create the coordinator and store
var coordinator: NSPersistentStoreCoordinator? = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("PassNote.sqlite")
var error: NSError? = nil
var failureReason = "There was an error creating or loading the application's saved data."
if coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error: &error) == nil {
coordinator = nil
// Report any error we got.
let dict = NSMutableDictionary()
dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
dict[NSLocalizedFailureReasonErrorKey] = failureReason
dict[NSUnderlyingErrorKey] = error
error = NSError.errorWithDomain("YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
// Replace this with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog("Unresolved error \(error), \(error!.userInfo)")
abort()
}
答案 0 :(得分:16)
尝试在Xcode中使用此命令: cmd + shift + k
啊,我明白了。我也在开发Swift,他们改变了一些标准的实现。您需要做的就是将函数更改为Xcode所说的内容。:)我的项目中有90个更改。
所以你需要把它改成这个:
NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
答案 1 :(得分:0)
在新的Xcode 6.3 Beta中运行我的代码时出现此错误。这是您第一次创建应用程序时生成的CoreData代码的一部分。
**********之前************* *********
//报告我们得到的任何错误。
让dict = NSMutableDictionary()
dict [NSLocalizedDescriptionKey] ="无法初始化应用程序保存的数据"
dict [NSLocalizedFailureReasonErrorKey] = failureReason
dict [NSUnderlyingErrorKey] =错误
error = NSError.errorWithDomain(" YOUR_ERROR_DOMAIN",代码:9999,userInfo:dict)
//用代码替换它以适当地处理错误。
// abort()使应用程序生成崩溃日志并终止。您不应该在运输应用程序中使用此功能,尽管它在开发过程中可能很有用。
NSLog("未解决的错误(错误),(错误!.userInfo)")
中止()
*********后************** *********
var dict = [String: AnyObject]()
dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
dict[NSLocalizedFailureReasonErrorKey] = failureReason
dict[NSUnderlyingErrorKey] = error
error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
// Replace this with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog("Unresolved error \(error), \(error!.userInfo)")
abort()
答案 2 :(得分:0)
快捷键4
如果此错误在核心数据中向您显示,只需从模拟器或手机中删除/卸载您的应用(如果您正在手机中运行),请单击 shift + cmd + H 转到首页并长按应用程序图标,现在即可清理并构建您的应用程序。
清洁-shift + cmd + k
内置-cmd + B
运行它。
显示此错误是因为您从一台计算机复制了项目的文件夹并将其传输到另一台计算机。
答案 3 :(得分:-1)
重置iOS模拟器上的内容和设置对我有用。