Hello. I feel a bit intimidated to ask an obvious question like this.
How do I display a list of EntityB for a selected EntityA?
In a Core Data, document based application, I define EntityA and EntityB in the datamodel. EntityA has a 1-to-many relationship to EntityB, call it contents (which has a reverse to-one relationship, say container).
I successfully display, add, remove objects in seperate tables. For this, I create two NSArrayController (one for each entity), specify the corresponding entity in the inspector window (Array Controller Attributes), and bind the instances to the File's Owner's managed object context (inspector window, Array Controller Bindings pane, Parameters).
Then, I also bind the Value of individual Table Columns Bindings to the aforementioned NSArrayControllers, arrangedObjects.
This basically is what the wizard does when I drag Core Data Entity objects from the Library to my window (unless I'm missing something).
I tried 2 approaches to display a list of (related) EntityB objects of a selected EntityA.
First, I just bound the Table View content to "EntityA Array Controller", Controller Key "selection", Model Key Path "contents".
After this, I bound the individual Table Column Value to "EntityA Array Controller", Controller Key "selection", Model Key Path "contents.propertyOfEntityB".
Second, I created a seperate Array Controller that binds to "EntityA Array Controller" selected objects, call it "Selected EntitiesB". Then bound the table column to the arranged objects of this Array Controller.
Nothing worked. I tried different combinations of selection and selectedObjects. I tried telling the NSTableView which objects it took.
At the time of this writing I am using Xcode 3.2.1, in OSX 10.6.2.
I suspect this can easily be done without writing any code at all. Or am I overestimating the power of Xcode's Core Data?
How do I display a list of EntityB for a selected EntityA?
In a Core Data, document based application, I define EntityA and EntityB in the datamodel. EntityA has a 1-to-many relationship to EntityB, call it contents (which has a reverse to-one relationship, say container).
I successfully display, add, remove objects in seperate tables. For this, I create two NSArrayController (one for each entity), specify the corresponding entity in the inspector window (Array Controller Attributes), and bind the instances to the File's Owner's managed object context (inspector window, Array Controller Bindings pane, Parameters).
Then, I also bind the Value of individual Table Columns Bindings to the aforementioned NSArrayControllers, arrangedObjects.
This basically is what the wizard does when I drag Core Data Entity objects from the Library to my window (unless I'm missing something).
I tried 2 approaches to display a list of (related) EntityB objects of a selected EntityA.
First, I just bound the Table View content to "EntityA Array Controller", Controller Key "selection", Model Key Path "contents".
After this, I bound the individual Table Column Value to "EntityA Array Controller", Controller Key "selection", Model Key Path "contents.propertyOfEntityB".
Second, I created a seperate Array Controller that binds to "EntityA Array Controller" selected objects, call it "Selected EntitiesB". Then bound the table column to the arranged objects of this Array Controller.
Nothing worked. I tried different combinations of selection and selectedObjects. I tried telling the NSTableView which objects it took.
At the time of this writing I am using Xcode 3.2.1, in OSX 10.6.2.
I suspect this can easily be done without writing any code at all. Or am I overestimating the power of Xcode's Core Data?