FROM : Ben
DATE : Thu Jan 03 20:03:02 2008
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
DATE : Thu Jan 03 20:03:02 2008
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
| Related mails | Author | Date |
|---|---|---|
| Ben | Jan 3, 20:03 | |
| Bill Bumgarner | Jan 3, 22:30 | |
| Chris Hanson | Jan 4, 04:11 |






Cocoa mail archive

