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: email@hidden
- Date: Thu, 14 May 2009 19:07:20 +0200
On 14.05.2009, at 16:55, Keary Suska wrote:
On May 14, 2009, at 5:51 AM, email@hidden wrote:
Now here is what has me utterly confused and my actual question:
In his tutorial Scott is setting up an NSObjectController (named
"ControllerAlias" there) and binds that to the "MyController"
instance with the explanation:
<quote>This little green box is your "bridge" between the code in
MyController.m and the bindings system.</quote>
The two NSArrayControllers afterwards are bound to that
'ControllerAlias' NSObjectController.
Aaron in his book has me creating an NSArrayController and bind
that directly to the instance with the array to be controlled.
Essentially skipping the NSObjectController entirely. When I just
thought it was my "bridge to the bindings system"?
I would really like to understand the difference in approach
between these two methods and also if there are any implications
by using or skipping an NSObjectController in between. Would
anyone find the time and inclination to explain this to me, please?
Well, these two examples do not solve the same problem, so compare/
contrast would not be useful. You need to understand the Model-View-
Controller (MVC) pattern as it is used in Cocoa. You will find this
the docs (just search for "cocoa patterns" and I bet you'll find it
easily). NSController and its subclasses (which include
NSObjectController and NSArrayController) were designed to be the
"C" in this pattern specifically for bindings. Have you read "Cocoa
Bindings Programming Topics"?
Additional info I would add: the important difference between the
two examples is that Scott's uses a tiered approach (common for
master-detail interfaces, for instance, in their simplest form),
where one controller provides the content for another controller,
while Aaron's is the more straightforward single-controller
approach (although iterate, these aren't approaches to the same
problem, but approaches to different problems). Note also the
purpose of NSObjectController vs NSArrayController. As the name
implies, the former is for binding to a single object, while the
latter is for binding to an array of objects.
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
Keary,
thank you for your response to my question. I especially found your
comment on the tiered approach aspect of Scott's example very
interesting.
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?
Thanks again!
Philipp
_______________________________________________
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