Re: KVO and master-detail NSTableViews
Re: KVO and master-detail NSTableViews
- Subject: Re: KVO and master-detail NSTableViews
- From: Stefan Reitshamer <email@hidden>
- Date: Fri, 5 Jun 2009 07:26:47 -0400
I think you're manually using KVO when you could (and perhaps
should) be using bindings. I also think you're setting up the
observations in the wrong direction. I wouldn't have the app
controller observe properties of the array controller. Mediating
controllers should bind to (thus, implicitly observe and set)
properties of the coordinating controller (or the model, reached
through the coordinating controller).
First, I don't know if you need the array controller for the pop-up
to manage the selection. I think you should bind the pop-up's
selectedObject to a (possibly new) property on the app controller.
This may require use of both the content and contentObjects bindings
of the pop-up to get selectedObject to be an appropriate object.
Second, I think the array controller for the left table would bind
to or through this property (the one bound to the pop-up's
selection) on the app controller.
Lastly, the array controller for the right table would bind through
the selection property of the array controller for the left table.
Put another way, bindings are meant to reduce or eliminate glue
code. You seem to be reproducing the sort of glue code that one
would typically have in the pre-bindings days, just using KVO (and
maybe bindings themselves) to trigger the glue code.
Thank you very much!
I got rid of the glue code altogether with your suggestions.
The trick was to bind the second NSArrayController's contentArray to
the pop-up's NSArrayController's selection's "commits" property (an
array), and the third NSArrayController's contentArray to the second
NSArrayController's selection's "commitObjects" property (an array).
Wow it's tough to put this bindings stuff into words.
- Stefan
_______________________________________________
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