Reputation: 1919
i have core data error, when i try save relation between Group <<->> Contact
i fetch one Contact from coredata by hashUser, and one Group by uid and try adding relation to-many with func
// extension CXDMContact
func addGroup(value: CXDMGroup) {
let items = self.mutableSetValueForKey("groups");
items.addObject(value)
}
when i try save it, i get exeption
CoreData: error: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. [<CXDMGroup 0x7fb7924aa770> valueForUndefinedKey:]: the entity Group is not key value coding-compliant for the key "id". with userInfo {
NSTargetObjectUserInfoKey = "<CXDMGroup: 0x7fb7924aa770> (entity: Group; id: 0xd0000000000c0000 <x-coredata://E66299CB-12A5-4152-8B49-8E9B3B68762F/Group/p3> ; data: {\n contacts = (\n \"0xd000000000040002 <x-coredata://E66299CB-12A5-4152-8B49-8E9B3B68762F/Contact/p1>\"\n );\n uid = 5;\n})";
NSUnknownUserInfoKey = id;
}
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<CXDMGroup 0x7fb7924aa770> valueForUndefinedKey:]: the entity Group is not key value coding-compliant for the key "id".'
but i not have any ID field, and if i look in managedObjectContext in the moment - i see
(lldb) po managedObjectContext.updatedObjects
▿ 2 elements
- [0] : <CXDMContact: 0x7fb7927f5270> (entity: Contact; id: 0xd000000000040002 <x-coredata://E66299CB-12A5-4152-8B49-8E9B3B68762F/Contact/p1> ; data: {
chatStatus = nil;
companyId = nil;
companyName = OWN;
companySubscription = nil;
connectedLoads = nil;
countryCode2 = nil;
departmentName = nil;
email = nil;
firstname = Ownname;
groups = (
"0xd0000000000c0000 <x-coredata://E66299CB-12A5-4152-8B49-8E9B3B68762F/Group/p3>"
);
jobTitle = nil;
lastname = Lastname;
messages = "<relationship fault: 0x7fb7924a25b0 'messages'>";
phone1 = nil;
phone2 = nil;
serialNumber = nil;
status = Offline;
timeZoneName = nil;
userHash = 1002;
})
- [1] : <CXDMGroup: 0x7fb7924aa770> (entity: Group; id: 0xd0000000000c0000 <x-coredata://E66299CB-12A5-4152-8B49-8E9B3B68762F/Group/p3> ; data: {
contacts = (
"0xd000000000040002 <x-coredata://E66299CB-12A5-4152-8B49-8E9B3B68762F/Contact/p1>"
);
uid = 5;
})
(lldb) po managedObjectContext.insertedObjects
0 elements
(lldb) po managedObjectContext.deletedObjects
0 elements
i don't understand where does key "id"? please help
Upvotes: 4
Views: 3149
Reputation: 80265
Look for an occurrence of trying to set or get id
instead of uid
somewhere in your controller.
Upvotes: 1
Reputation: 46718
This issue, as the error hints at, has to do with something observing the save of the context. If you are using a NSFetchedResultsController
or something else that monitors that event it is there that you have the issue. Perhaps a typo somewhere in a UITableViewCell
?
Upvotes: 5