Binding to selection of NSArrayController
Binding to selection of NSArrayController
- Subject: Binding to selection of NSArrayController
- From: Jonathan Taylor <email@hidden>
- Date: Tue, 23 Sep 2014 17:15:08 +0100
Hi all,
I feel this should be a very simple question, but I am struggling with it - the tutorials and online info I can find is either 5 years out of date or seem to imply that I am doing everything right!
In my code I have an NSMutableArray of “message” objects, each with a number of properties defined on them. In the GUI this is wired up to a table view, via an NSArrayController. That all seems to work fine, and the object properties are listed in the table[*].
Underneath the table I want to display some more detailed information about the currently-selected object in the table. I would have thought that I could do this just by binding the relevant NSTextField to MessageArray.selection.myExtendedInformationProperty. This works up to a point, in that I do see text appearing in the text field. However it does not update when the selection in the table view changes, which is what I had intended to happen.
This is basically what happens on p18 of this tutorial (http://web.stanford.edu/class/cs193e/Downloads/CocoaBindingsTutorial.pdf), and (although it’s referring to a much older version of IB) I think I have done what they do.
Can anyone suggest what I may have omitted to do here, or why my approach is wrong? Thanks for any advice.
Cheers
Jonny.
[*] One slight glitch - if I add an object to the NSMutableArray then it does not immediately show up in the table, I have to call will/didChangeValueForKey on the property that returns the array. I don’t know if that is expected behaviour (maybe I should be adding via the array controller somehow?). This is not a problem, but I mention it for completeness, just in case it’s indicative of something funny that is going on that I don’t fully appreciate.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden