Re: nested autorelease pools?
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