FROM : Paul Szego
DATE : Thu Mar 20 23:27:30 2008
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.
DATE : Thu Mar 20 23:27:30 2008
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.
| Related mails | Author | Date |
|---|---|---|
| Jonathan Dann | Mar 19, 12:37 | |
| Cathy Shive | Mar 19, 13:19 | |
| Jonathan Dann | Mar 20, 02:19 | |
| Cathy Shive | Mar 20, 08:40 | |
| Jonathan Dann | Mar 20, 12:35 | |
| Cathy Shive | Mar 20, 13:29 | |
| Paul Szego | Mar 20, 23:27 | |
| Jonathan Dann | Mar 21, 21:49 | |
| Cathy Shive | Mar 21, 22:31 | |
| Steve Weller | Mar 22, 04:25 | |
| Steve Weller | Mar 22, 04:31 | |
| Cathy Shive | Mar 22, 05:18 |






Cocoa mail archive

