Search code examples
cocoacore-datacocoa-bindingsnstreecontrollernsbrowser

NSBrowser not Repopulating children from NSTreeController after File Load via Core Data


I have a Core Data based Document backed application making heavy use of cocoa-bindings. I'm using an NSTreeController for populating an NSBrowser. The main entity has a set of children, accessible via a relationship called "children". I have no problem adding children and displaying them in the NSBrowser. However, after I save a document and reopen it, only the main entities show in the browser, not their children. I have verified by examining the file that the children are being saved along with a proper relationship (and inverse) to the main entities. Has anyone else ever seen this? Is there some obvious binding/setting that I'm probably missing?


Solution

  • I neglected to mention that I'm using ordered relationships. It seems this behavior (or lack of behavior) is related to bugs in Core Data's use of ordered sets in relationships. I changed the relationships to not being ordered and they started loading correctly after being saved. For more information see this question: How to bind NSTreeController's Children to Core Data ordered to-many-relationship?