Well I've got much further along with myFirstCocoaApp and have now run into a bit of a problem with regards to a custom controller I'm working on and how to get it to display the correct info.
The data model set up is as follows
There are two array controllers A & B where B sets it's content array based on A.
I have a TableView displaying two of the properties of the objects in B (they're NSManagedObjects) and then have a number of text fields displaying all the properties.
What I'd like to do is replace the text fields with a single custom NSView subclass that displays all the property strings of the selected NSManagedObject with specific formatting.
Now at the moment what I'm thinking of doing is using
and the addObserver: etc. to observe whenever NSArrayController B changes it's contents.
As far as I can make out I can only get the whole array from NSArrayController using -selectedObjects and reading that into an array.
So far so good. But how do I get it to change the selected object within that array based on the selection in the tableView?
I've got something working where my custom class gets the selected row number from the tableView and then looks that up in the array populated from B. But this requires an action to be triggered from a button. How can I get it to update whenever the user changes the selection in the table view?
Thanks in advance guys
The data model set up is as follows
There are two array controllers A & B where B sets it's content array based on A.
I have a TableView displaying two of the properties of the objects in B (they're NSManagedObjects) and then have a number of text fields displaying all the properties.
What I'd like to do is replace the text fields with a single custom NSView subclass that displays all the property strings of the selected NSManagedObject with specific formatting.
Now at the moment what I'm thinking of doing is using
Code:
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id) object
change:(NSDictionary *)change
context:(void *)context
and the addObserver: etc. to observe whenever NSArrayController B changes it's contents.
As far as I can make out I can only get the whole array from NSArrayController using -selectedObjects and reading that into an array.
So far so good. But how do I get it to change the selected object within that array based on the selection in the tableView?
I've got something working where my custom class gets the selected row number from the tableView and then looks that up in the array populated from B. But this requires an action to be triggered from a button. How can I get it to update whenever the user changes the selection in the table view?
Thanks in advance guys