Re: Caution regarding NSDirectoryEnumerator
Re: Caution regarding NSDirectoryEnumerator
- Subject: Re: Caution regarding NSDirectoryEnumerator
- From: "John C. Randolph" <email@hidden>
- Date: Mon, 17 Jun 2002 15:39:35 -0700
On Monday, June 17, 2002, at 02:53 PM, Ken Thomases wrote:
You might find this less ugly and kludgy (or, you might find it
moreso):
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
while(anObject = [enumerator nextObject])
{
// do stuff
[pool release];
pool = [[NSAutoreleasePool alloc] init];
}
[pool release];
Keep in mind, if "// do stuff" uses the continue statement, then that
iteration won't release the autorelease pool. Probably not a problem
in most cases.
I'd also point out that it's probably overkill to release the
pool on *every* iteration.
-jcr
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.