• 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
Re: nested autorelease pools?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nested autorelease pools?


  • Subject: Re: nested autorelease pools?
  • From: Uli Kusterer <email@hidden>
  • Date: Sat, 5 Nov 2005 21:28:38 +0100

Am 01.11.2005 um 21:16 schrieb Brian O'Brien:
-(id) init
{
	self = [super init];
	mypool = [[NSAutoreleasePool alloc] init];
	return self;
}

-(void) dealloc
{
	[mypool release];
	[super dealloc];
}

-(void) mymethod
{
	for (i=0; i < 100; ++i)
	{
		NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
		... // Do some stuff
		[p release];
	}
}

Others have explained here why this won't work, but if I guess correctly what you're trying to do, then I suggest you use an NSMutableArray instead of an NSAutoreleasePool. Instead of autoreleasing objects, add them to that array. As an array retains all objects inside it, they'll all get released when you release the array (except if they're still needed by someone else, obviously, but then that's what we want).


Cheers,
-- M. Uli Kusterer
http://www.zathras.de


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >nested autorelease pools? (From: "Brian O'Brien" <email@hidden>)

  • Prev by Date: Re: Question about associating file types to applications
  • Next by Date: Re: NSPropertyDescription userInfo
  • Previous by thread: Re: nested autorelease pools?
  • Next by thread: NSSpellChecker and learning words.
  • Index(es):
    • Date
    • Thread