• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Garbage collection, leaks and drains
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • View controllers (was Re: Garbage collection, leaks and drains)
      • From: Chris Hanson <email@hidden>
    • Re: Garbage collection, leaks and drains
      • From: Bill Bumgarner <email@hidden>
  • Prev by Date: Re: How do I trigger IBAction with custom "button" based on NSView...
  • Next by Date: Re: Binding table column to complex NSDictionary
  • Previous by thread: Re: How do I trigger IBAction with custom "button" based on NSView...
  • Next by thread: Re: Garbage collection, leaks and drains
  • Index(es):
    • Date
    • Thread