Error after updating kernel data model - Unrecognized selector sent to instance

I get the following error after adding a string property called Unique Identifier to my Enitiy / NSManagedObject called Labels . However, this is not the Unique Identifier that the compliment is not happy with.

2016-08-20 02: 20: 08.394 AN [22499: 8730414] - [Folders AN.Labels]: unrecognized selector sent to instance 0x7ffe907e1a80 2016-08-20 02: 20: 08.405 AN [22499: 8730414] *** Application termination due to non-displayable exception 'NSInvalidArgumentException', reason: '- [Folders AN.Labels]: unrecognized selector sent to instance 0x7ffe907e1a80'

Here is my NSManagedObject class

 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 } } } 

I made sure that the application uses the new coreData model and has the following in my coreData stack. I have not had this problem for some time, as my application automatically updates to use the latest kernel data model.

 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 } 

Does anyone have any suggestions?

+5
source share
1 answer

Check the relationship between shortcuts and folders in the underlying data model. You may have feedback with a name other than shortcuts.

+3
source

All Articles