0

I've an NSManagedObjectContext with two entities, A and B. I've an NSArrayController bound to the NSManagedObjectContext and an NSTableView. The NSArrayController is set to list entities of type B. The array controller then feeds the table view.

The NIB where the array controller sits is called by a an NSWindowController. On init I add one instance of each object but when I get to windowDidLoad the managed object context has been populated but the array controller is empty.

Using gdb I can print the MOC visible in the window controller and the one bound to the array controller and they both have the same address.

Any clues on how to debug this?

ruipacheco
  • 15,025
  • 19
  • 82
  • 138
  • Did you check the "Prepares Content" checkbox in the Attributes Inspector for your NSArrayController? Easy to forget, impossible to debug... – Roger Apr 12 '12 at 00:03
  • If you save your context, does the data appear in your store? – Roger Apr 13 '12 at 07:21
  • Yes it does. I can get data out of my MOC without any problems. If I add the data to the array controller manually it will also appear on the table. What I can't do is make the array controller see the data in the MOC, even though it's bound to the same MOC. – ruipacheco Apr 15 '12 at 18:31
  • This should just work. Double check all your bindings especially the ones for your table view. This stuff is near impossible to debug if there are no exceptions generated. As you did not post any details on this, I presumed no exceptions appear... – Roger Apr 15 '12 at 23:29
  • Nothing whatsoever. No feedback at all. I know stuff is in the MOC, I can add it to the array controller manually. What I can't do is have the array controller see the stuff in the MOC. – ruipacheco Apr 16 '12 at 17:05
  • Fixed it. Deleted the controller and the NIB I had and wrote the whole code from scratch. I smell an Xcode bug. – ruipacheco Apr 16 '12 at 19:30

1 Answers1

0

Deleted the NIB and controller and created the code from scratch. Things seem to work perfectly. I suspect this was a bug in Xcode.

ruipacheco
  • 15,025
  • 19
  • 82
  • 138