Skip navigation.
 
mlSetting NSObjectController's to file's owner
FROM : André Pang
DATE : Thu May 15 09:21:23 2008

Hi all,

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 would think 
that setting an NSObjectController's content object to the file's 
owner is a reasonably common scenario, so I can't be alone in 
experiencing this memory leak.)  Binding a control directly to the 
file's owner seems kinda skanky.

Also, I've Googled around a ton and found a lot of references to 
memory leaks that occur when binding to the file's owner, but it 
appears that those bugs are fixed up in 10.4.  (The last messages and 
blog posts I saw about this topic were from 2004.)  Is that correct?


--
% Andre Pang : trust.in.love.to.save  <http://www.algorithm.com.au/>

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