Re: Correct use of NSViewController
Re: Correct use of NSViewController
- Subject: Re: Correct use of NSViewController
- From: Paul Szego <email@hidden>
- Date: Fri, 21 Mar 2008 11:27:30 +1300
On 21/03/2008, at 12:35 AM, Jonathan Dann wrote:
Hi Cathy,
Thanks again for your advice. I've got it working now and I'm almost
back I where I was before refactoring, I'm now running into a
bindings problem.
Before using the view controllers I had put 2 tree controllers in my
window controller's nib, 2 outline views were then bound to these
and the tree controllers themselves got their content from an object
controller that was bound to the the keypath [(Window
Controller)File's Owner].document. So the object controller was a
proxy for my document and the tree controllers had shorter keypath
to traverse to get to the array they needed in my document subclass.
Now when I do this I have the tree controllers and the document
proxy object controller in my view controller's nib. The only way I
can see to getting to the document is using the keypath
Have you considered using the representedObject property of the
NSViewController?
To quote the API docs for NSViewController:
"...a generic representedObject property, to make it easy to establish
bindings in the nib to an object that isn't yet known at nib-loading
time or readily available to the code that's doing the nib loading."
In my code I create the view controller from the window controller,
then set the representedObject. In my case it's usually the document,
since I have the necessary controller objects in the document so that
I can share selection status across various windows and views from
different NIB's easily (remember that NSDocument is part of the
*controller* layer in MVC, not the model).
HTH, Paul.
_______________________________________________
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