3

升级到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()

}
4

4 回答 4

16

尝试在 Xcode 中使用此命令:cmd + shift + k

啊,我明白了。我也在用 Swift 开发,他们改变了一些标准的实现。

您需要做的就是将函数更改为 Xcode 所说的内容.. :) 我的项目中有 90 处更改。

所以你需要把它改成这样: NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)

于 2014-10-22T08:04:01.483 回答
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("未解决的错误 (error), (error!.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()

于 2015-02-23T00:14:04.990 回答
0

斯威夫特 4

如果此错误在核心数据中显示您只需从模拟器或手机中删除/卸载您的应用程序(如果您在手机中运行)单击shift + cmd + H转到主页并长按应用程序图标,现在清理并构建您的应用程序.

清洁 - shift + cmd + k

内置 - cmd + B

运行。

显示此错误是因为您从一台计算机复制了项目的文件夹并将其传输到另一台计算机。

于 2018-08-02T08:45:19.860 回答
-1

在 iOS 模拟器上重置内容和设置对我有用。

于 2015-05-22T20:00:55.237 回答