2014-10-22 72 views
3

升级到xCode6.1后,我无法编译上一次确定的项目。我从来没有改变这个文件中的任何东西。请帮帮我 !!!当升级到Xcode 6.1时,在AppDelegate.swfit中编译错误

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() 

} 

回答

16

尝试在Xcode使用该命令: CMD +移位+ K

啊,我看。我也在Swift中开发,他们改变了一些非标准的实现。

所有你需要做的是改变功能成什么样的Xcode是说.. :)我喜欢在我的项目90种变化。

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

+0

太棒了!非常感谢! – 2014-10-22 08:15:51

+0

不错,真是太棒了! – 2014-10-25 09:11:35

+0

太棒了。谢谢 – 2014-12-12 02:17:00

0

我跑我的,在新的Xcode 6.3测试版代码时有此错误。这是您首次创建应用程序时生成的CoreData代码的一部分。

*********************************之前************ *******************************

//报告中,我们有任何错误。

设字典=的NSMutableDictionary()

字典[NSLocalizedDescriptionKey] = “无法初始化应用程序的保存数据”

字典[NSLocalizedFailureReasonErrorKey] = failureReason

字典[NSUnderlyingErrorKey] =错误

error = NSError.errorWithDomain(“YOUR_ERROR_DOMAIN”,code: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()

-1

重置内容和设置上的iOS模拟器为我工作。

+0

这是一条评论。你必须等到你有足够的声望,然后你可以发布它们。 – kaz 2015-05-22 20:19:42