Re: [Newbie] Binding an NSArrayController with/without NSObjectController
Re: [Newbie] Binding an NSArrayController with/without NSObjectController
- Subject: Re: [Newbie] Binding an NSArrayController with/without NSObjectController
- From: Keary Suska <email@hidden>
- Date: Thu, 14 May 2009 12:40:34 -0600
On May 14, 2009, at 11:07 AM, email@hidden wrote:
To possibly refine my initial question a bit better though:
In Scott's example I can *remove* the NSObjectController and bind
the NSArrayController (he's binding to that NSObjectController)
*directly* to the "MyController" instance in IB. And from my
testing: it's still working exactly the same. So I'm still not sure
why the NSObjectController is placed "in between" there. What is its
purpose?
Allow me the little sketch to illustrate my point:
Scott's tutorial) ControllerInstance <--- NSObjectController <---
NSArrayController <--- NSArrayController
Alternative) ControllerInstance <--- NSArrayController <---
NSArrayController
What's that "NSObjectController" in Scott's example for and what is
it doing that will not happen in the "Alternative" binding approach?
I haven't reviewed both examples in detail, but the most likely answer
is "no difference at all". You should be able to--adjusting the
bindings appropriately in each case--remove the NSObjectController
from the first example and insert one into the second example, without
any change in behavior. I have seen a number of examples from Apple
that use NSObjectControllers in this way, so it may a situation of
convention, but also refer to Quincy's response.
I would add that an otherwise useless NSObjectController is
particularly useful in cases where the File's Owner maintains the
model data. Binding to File's Owner may create retain cycles, so in
these cases I have the owner offload the data-binding to an object
controller. I also find them useful in Interface Builder as the app
will maintain a list of keys and auto-suggest keys when specifying
bindings. I wouldn't recommend using the class for just this purpose,
but NSObjectController does have its uses.
Best.
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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