Relationship fault?



I’ve been working my way through the book (which I love, by the way) and got to the Core Data chapter. On Page 364 it says that I should be able to add new locations but I found that, although I could add new locations - the table wasn’t updating.

So I threw in a few NSLogs to see what was happening and noticed that when returning the contents of the NSManagedObject ‘locations’ the output was listing a relationship fault. Here’s an example of my output…

"<NSManagedObject: 0x6412f30> (entity: Location; id: 0x6444890 <x-coredata:///Location/t6E97E61E-DB48-4AE1-AA36-BA5B13103DDC2> ; data: {\n inventories = (\n );\n label = 11111;\n})", "<NSManagedObject: 0x645a5a0> (entity: Location; id: 0x641c320 <x-coredata:///Location/t6E97E61E-DB48-4AE1-AA36-BA5B13103DDC6> ; data: {\n inventories = (\n );\n label = aaaaa;\n})", "<NSManagedObject: 0x6157df0> (entity: Location; id: 0x6101fd0 <x-coredata://E4575355-9BA4-499C-842F-5908A3BBE628/Location/p4> ; data: {\n inventories = \"<relationship fault: 0x6469190 'inventories'>\";\n label = abded12345;\n})", "<NSManagedObject: 0x6420320> (entity: Location; id: 0x6414040 <x-coredata:///Location/t6E97E61E-DB48-4AE1-AA36-BA5B13103DDC8> ; data: {\n inventories = (\n );\n label = \"efwefwqefwqef wef\";\n})", "<NSManagedObject: 0x6158070> (entity: Location; id: 0x61489d0 <x-coredata://E4575355-9BA4-499C-842F-5908A3BBE628/Location/p1> ; data: {\n inventories = \"<relationship fault: 0x645abb0 'inventories'>\";\n label = erferf;\n})", "<NSManagedObject: 0x61580d0> (entity: Location; id: 0x6150480 <x-coredata://E4575355-9BA4-499C-842F-5908A3BBE628/Location/p2> ; data: {\n inventories = \"<relationship fault: 0x6442900 'inventories'>\";\n label = gwergwergwe;\n})", "<NSManagedObject: 0x6158130> (entity: Location; id: 0x6148500 <x-coredata://E4575355-9BA4-499C-842F-5908A3BBE628/Location/p3> ; data: {\n inventories = \"<relationship fault: 0x645a2f0 'inventories'>\";\n label = testxxxx;\n})"

I also noticed that it doesn’t always list a relationship fault. As you can see in the example above, some of the entries are perfectly fine. Any ideas why this would be? I can’t find any problems anywhere in my code. There are no warnings or errors but it doesn’t show any of these entries in the table and I wondered if there was something wrong with my data model somehow?



UPDATE: I’ve figured out why nothing was being displayed in the table. What I’d done is left in some of the boilerplate code for the method ‘numberOfSections’ (which I’d set to return 0 at the start of the chapter). Removed this and it unsurprisingly started showing results in the table. :blush:

However, the NSLog continues to show ‘relationship fault’ which is worrying! Any ideas?