I have an entity named Person that may have one home, and an entity named Home that may have one to N homes:
Then I have two array controllers:
- Homes Controller, bound with managed object context, in entity mode: Home;
- People Controller, bound with managed object context, in entity mode: person.
I have a cell based table view, bound with the People Controller.I am able to display successfully the first three columns (name, surname and age), but the problem is with the 4th column: the home's name.Inside the column there is a popup button cell, these are the bindings:
- Content: Homes Controller.arrangedObjects ;
- Content values: Homes Controller.arrangedObjects.name;
- Selected object: People Controller.home.
The problem comes at runtime, when I try to click to the popup button to choose the home:
Like you see instead of the choice I see "Core data relationship fault", and if I try to change the home by clicking on the menu items, I see a lot of code printed to the console, I post only the most significant line:
2012-11-04 01:47:45.181 Test[4390:303] [<NSManagedObject 0x100156e60> valueForUndefinedKey:]: the entity Home is not key value coding-compliant for the key "(null)".
And after this the application freezes.
Edit: With some debug I am now able to know the state of the object when the exception occurs:
2012-11-09 02:42:02.495 Test[4650:303] <NSManagedObject: 0x100157460> (entity: Person; id: 0x10013d9d0 <x-coredata:///Person/t0182F6F4-9CCC-4F51-A82F-D00CE026DB752> ; data: {
age = 20;
home = "0x101953480 <x-coredata:///Home/t0182F6F4-9CCC-4F51-A82F-D00CE026DB753>";
name = "New Name";
surname = "New Surname";
})
2012-11-09 02:42:02.497 Test[4650:303] <NSManagedObject: 0x101953420> (entity: Home; id: 0x101953480 <x-coredata:///Home/t0182F6F4-9CCC-4F51-A82F-D00CE026DB753> ; data: {
name = "New Home";
people = (
"0x10013d9d0 <x-coredata:///Person/t0182F6F4-9CCC-4F51-A82F-D00CE026DB752>"
);
It seems that the values are regular, there are not nil keys.I suspect the problem is with the bindings.