gpt4 book ai didi

swift - 升级到 Xcode 6.1 时 AppDelegate.swfit 中的编译错误

转载 作者:搜寻专家 更新时间:2023-10-31 21:51:13 25 4
gpt4 key购买 nike

升级到xCode6.1后,我无法编译上次正常的项目。我从未更改过此文件中的任何内容。请帮助我!!!

AppDelegate.swift:75:29:

errorWithDomain(_:code:userInfo:)' 不可用:使用对象构造 '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()

}

最佳答案

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

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

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

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

关于swift - 升级到 Xcode 6.1 时 AppDelegate.swfit 中的编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26502746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com