Re: Binding Tree Controller to a singleton
Re: Binding Tree Controller to a singleton
- Subject: Re: Binding Tree Controller to a singleton
- From: Florent Pillet <email@hidden>
- Date: Sun, 16 Mar 2008 22:36:14 +0100
Michael Hanna wrote:
My question is, how do I make a keypath from the tree controller to
the treeModel, since it's sitting inside a singleton? Would
programmatically setting the binding accomplish this?
If you have a NSApp subclass, an easy way to accomplish this is to add
an accessor method there, i.e.:
- (id)dataModelMgr
{
return [MyDataModelManager getInstance];
}
Then bind your tree controller to the "Shared Application" object with
keypath @"dataModelMgr.treeDataModel" (or simplify this and have your
accessor directly return the tree data model).
Also, would it be necessary for MyTreeDataModel be an
NSArrayController subclass?
Why should it? As long as it complies with the NSTreeController
requirements (see the documentation) you should be fine.
Note, though, that NSTreeController can be a pain to work with.
Especially if you plan on supporting 10.4. But that's just my opinion...
--
Florent Pillet http://www.florentpillet.com
Software consultant - Mobile devices, desktop and server platforms
Mac OS X, iPhone, WinMob, Palm OS Skype callto://florent.pillet
_______________________________________________
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