FROM : André Pang
DATE : Thu May 15 16:53:28 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.)
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/>
DATE : Thu May 15 16:53:28 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.)
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/>
| Related mails | Author | Date |
|---|---|---|
| André Pang | May 15, 09:21 | |
| Ken Thomases | May 15, 10:36 | |
| Chris Suter | May 15, 14:09 | |
| André Pang | May 15, 16:53 | |
| Michael Babin | May 15, 17:59 |






Cocoa mail archive

