Skip navigation.
 
mlRe: Setting NSObjectController's to file's owner
FROM : Chris Suter
DATE : Thu May 15 14:09:24 2008

On 15/05/2008, at 5:21 PM, André Pang wrote:

> I have a nib file containing an NSObjectController.  The 
> NSObjectController's content is set to the File's Owner proxy 
> object, and this creates a retain cycle.  (The file's owner never 
> gets deallocated because the object controller retains it, and the 
> object controller never gets deallocated because the file's owner 
> retains it as an IBOutlet.)
>
> This is obviously a bad thing to do, but I always thought that it 
> was good design for views and controls to be bound to an 
> NSObjectController rather than the file's owner directly, since 
> NSObjectController then takes care of all the NSEditor protocol 
> stuff, you get auto-completion for model key names in Interface 
> Builder, etc.  Is there a better method than what I'm doing?


I wouldn't set the content to file's owner. I think you should set the 
content to an object that's contained by the file's owner, i.e. make 
the file's owner a controller object that owns the NSObjectController 
and has a reference/owns the content object.

- Chris

Related mailsAuthorDate
mlSetting NSObjectController's to file's owner André Pang May 15, 09:21
mlRe: Setting NSObjectController's to file's owner Ken Thomases May 15, 10:36
mlRe: Setting NSObjectController's to file's owner Chris Suter May 15, 14:09
mlRe: Setting NSObjectController's to file's owner André Pang May 15, 16:53
mlRe: Setting NSObjectController's to file's owner Michael Babin May 15, 17:59