Theocacao
Leopard
Design Element
Comment on "Bindings and File's Owner"
by Jamie Kirkpatrick — Mar 20
This is nice, but if you want to proxy the original file's owner in this way you'll need to go a little further.

In your NSWindowController subclass override awakeFromNib: and release with something that looks like this:

- (void) awakeFromNib;
{
// filesOwnerProxy == NSObjectController in the nib
[filesOwnerProxy setContent:self];
}

- (oneway void) release;
{
// special case when count is 3, we are being retained twice by the object controller...
if ( [self retainCount] == 3 )
{
[super release];
[filesOwnerProxy setContent:nil];
return;
}

[super release];
}

When you setContent: in the NSObjectController you get two extra retains in the new contentObject. This is a nice solution since you can be sure that the extra two retains will be from your objectController, and you can safely bind as much as you like to that controller. The only issue will be if apple changes their NSObjectController etc code.
Back to "Bindings and File's Owner"
Design Element

Copyright © Scott Stevenson 2004-2015