Question about NSTreeController/NSOutlineView instance cleanup
Question about NSTreeController/NSOutlineView instance cleanup
- Subject: Question about NSTreeController/NSOutlineView instance cleanup
- From: Markus Spoettl <email@hidden>
- Date: Thu, 10 Apr 2008 18:07:45 -0700
Hi,
I have a simple test application (modeled after the SourceView
sample) which is a NSDocument based application. The NSDocument
derived class contains a root NSMutableArray which serves as the
content for an NSOutlineView which is attached to the content through
binding.
@interface MyDocument : NSDocument {
[...]
NSMutableArray *treeContent;
[...]
}
treeContent is never accessed directly (except for initialization and
deallocation), it's managed by a NSTreeController instance that is
part of the document's nib file.
The problem now is i -(void)dealloc: for MyDocument:
- (void)dealloc
{
[treeContent release];
[super dealloc];
}
This causes the following debugger log:
----------------------
2008-04-10 17:50:02.641 AppDocTest[7852:813] An instance 0x160ad0 of
class TreeNode is being deallocated while key value observers are
still registered with it. Observation info is being leaked, and may
even become mistakenly attached to some other object. Set a breakpoint
on NSKVODeallocateBreak to stop here in the debugger. Here's the
current observation info:
<NSKeyValueObservationInfo 0x1690a0> (
<NSKeyValueObservance 0x167a30: Observer: 0x160c20, Key path:
children, Options: <New: NO, Old: NO, Prior: NO> Context: 0xa00be78c,
Property: 0x160530>
<NSKeyValueObservance 0x1677d0: Observer: 0x160c20, Key path: isLeaf,
Options: <New: NO, Old: NO, Prior: NO> Context: 0xa00be78c, Property:
0x14f140>
)
----------------------
If I interpret this correctly I'm removing my tree content from under
the NSTreeController while it's still using it. If found that when I add
[treeContent removeAllObjects];
before [treeContent release] this log entry goes away, but I'm not at
all convinced this is the right procedure. So what is? How do I tell
the NSTreeController to remove all ties to my nodes because we are
shutting down?
I'm very new to Cocoa so there might be something I did wrong in the
setup. I very closely followed the SourceView sample though which
works with a NSWindowController instead of NSDocument and does not
produce this log entry) Thanks for any pointers.
Regards
Markus
--
__________________________________________
Markus Spoettl
_______________________________________________
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