Garbage collection, leaks and drains
Garbage collection, leaks and drains
- Subject: Garbage collection, leaks and drains
- From: Ben <email@hidden>
- Date: Thu, 3 Jan 2008 19:03:02 +0000
Hi list,
I'm having a little bit of a brain fuse while building my first
garbage-collected app as I a unsure if I'm running the risk of leaks
or messaging deallocated objects. It's a fairly standard NSDocument
based application, with a source-list and main view in the document
window. The main view is an NSBox, which has a view substituted in
when the selection in the source list changes.
Most of these views are in separate nib files and their file's owner
is a similarly named class (for example GroupView.nib has
GroupViewManager.h/m). The portion of code I am using for this swap is
as follows (psuedo-code in places):
if ( newSelection is of type 'Group' )
{
GroupViewManager *groupViewManager = [[GroupViewManager alloc] init];
[NSBundle loadNibNamed:@"GroupView" owner:groupViewManager];
[contentBox setContentView:[groupViewManager mainView]];
}
else
{
[contentBox setContentView:fallbackView];
}
where contentBox is the NSBox and fallbackView a default NSView.
I can't see any obvious leaks in ZoneMonitor, nor are there any
crashes from messages deallocated objects, but this code just doesn't
seem *right*. Is this the sensible way of doing things? Or am I just
being overly neurotic?
Any replies that can clear this up will be much appreciated.
-- Ben
_______________________________________________
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