gpt4 book ai didi

ios - 更新核心数据模型后出错 - 无法识别的选择器发送到实例

转载 作者:搜寻专家 更新时间:2023-10-30 23:15:01 25 4
gpt4 key购买 nike

将名为 Unique Identifier 的字符串属性添加到名为 LabelsEnitiy/NSManagedObject 后,出现以下错误>。然而,编译器不满意的不是 Unique Identifier

2016-08-20 02:20:08.394 AN[22499:8730414] -[AN.Labels folders]: unrecognized selector sent to instance 0x7ffe907e1a80 2016-08-20 02:20:08.405 AN[22499:8730414] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AN.Labels folders]: unrecognized selector sent to instance 0x7ffe907e1a80'

这是我的 NSManagedObject 类

class Labels: NSManagedObject {

@NSManaged var title: String?
@NSManaged var details: String
@NSManaged var date: NSDate?
@NSManaged var uniqueIdentifier: NSString?

@NSManaged var arrayOfFolders: [Folders]
@NSManaged var folder: Folders?
@NSManaged var folders: NSSet

override func awakeFromFetch() {
super.awakeFromFetch()
self.regenerateFolders()
}

func regenerateFolders() {
let date = NSSortDescriptor(key: "date", ascending: false)
if let array = folders.sortedArrayUsingDescriptors([date]) as? [Folders] {
self.arrayOfFolders = array
}
}
}

我已确保该应用程序使用新的 coreData 模型并在我的 CoreData 堆栈中包含以下内容。我已经有一段时间没有遇到这个问题了,因为我的应用会自动更新以使用最新的核心数据模型。

var storeDirectoryURL: NSURL {
return try! NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: true)
}

var storeURL: NSURL {
return self.storeDirectoryURL.URLByAppendingPathComponent("SingleViewCoreData.sqlite")
}

func setupCoreData() {
let modelURL = NSBundle.mainBundle().URLForResource("AN", withExtension: "momd")
let model = NSManagedObjectModel(contentsOfURL: modelURL!)

try! NSFileManager.defaultManager().createDirectoryAtURL(self.storeDirectoryURL, withIntermediateDirectories: true, attributes: nil)

let coordinator = NSPersistentStoreCoordinator(managedObjectModel: model!)
let options = [NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true]
try! coordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: self.storeURL, options: options)

managedObjectContext = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
managedObjectContext.persistentStoreCoordinator = coordinator
managedObjectContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
}

有人有什么建议吗?

最佳答案

检查核心数据模型中标签和文件夹之间的关系。您可以将反向关系命名为标签以外的名称。

关于ios - 更新核心数据模型后出错 - 无法识别的选择器发送到实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39049671/

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