Re: Setting NSObjectController's to file's owner
Re: Setting NSObjectController's to file's owner
- Subject: Re: Setting NSObjectController's to file's owner
- From: André Pang <email@hidden>
- Date: Fri, 16 May 2008 00:53:28 +1000
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.)
Hmm, I just created a small test application to try to reproduce this
problem and couldn't get the retain cycle to happen. It's a dead-
simple document-based Cocoa application with a single
NSObjectController in the nib file, with a single text field binding
that was bound through the object controller to an ivar in the file's
owner.
However, now the weird thing is that I call -[objectController
release] in the file's owner -dealloc (which I guess should be the
correct behaviour, since the object controller is declared as an
IBOutlet and is a top-level nib file object), I get into an infinite
"release cycle" loop. Test program here, for those willing to lend a
hand:
http://algorithm.com.au/tmp/NSObjectControllerRetainCycleTest.zip
Am I completely misunderstanding memory management of bindings/nib
files objects?
One more note: in the application where I was having this retain cycle
problem, I deleted the content outlet from the object controller in
the .nib file, and instead set it programmatically via -
setContent:self in the document's -awakeFromNib, balanced by a -
setContent:nil in the document's -close method. That fixed it, which
strongly implied that there was a retain cycle with the object
controller and the file's owner object (the NSDocument subclass). I'm
very puzzled.
Cheers,
Andre.
--
% Andre Pang : trust.in.love.to.save <http://www.algorithm.com.au/>
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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