• 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: Caution regarding NSDirectoryEnumerator
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Caution regarding NSDirectoryEnumerator (From: "Ken Thomases" <email@hidden>)

  • Prev by Date: Re: Protecting Software w/ Software License Keys...
  • Next by Date: NSStepper
  • Previous by thread: Re: Caution regarding NSDirectoryEnumerator
  • Next by thread: Printing in OSX...
  • Index(es):
    • Date
    • Thread