• 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: fast enumeration
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fast enumeration


  • Subject: Re: fast enumeration
  • From: Jens Alfke <email@hidden>
  • Date: Sat, 27 Apr 2013 11:21:16 -0700

On Apr 27, 2013, at 11:11 AM, Boyd Collier <email@hidden> wrote:

> 	NSEnumerator *myEnumerator = [arrayOfLabels objectEnumerator];
> 	NSString *aString = [myEnumerator nextObject];  // gets us past the first element
>  	NSLog(@"the label is %@", aString);		// just to check; doesn't get used
>
> 	NSArray *arrayOfLabels = [myEnumerator allObjects];
>
> 	for (aString in arrayOfLabels) {
> 		// these are the strings that I'm interested in and will use
> 		NSLog(@"the label from enumeration is %@", aString);
> 	}

You don't need to create a separate array, since NSEnumerator already supports fast-enumeration.

	NSEnumerator *myEnumerator = [arrayOfLabels objectEnumerator];
	(void)[myEnumerator nextObject];  // gets us past the first element
	for (aString in myEnumerator) {
		...
	}

—Jens
_______________________________________________

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:
    • Re: fast enumeration
      • From: Boyd Collier <email@hidden>
References: 
 >fast enumeration (From: Boyd Collier <email@hidden>)

  • Prev by Date: fast enumeration
  • Next by Date: How to create a popup panel like Safari 6 downloads?
  • Previous by thread: fast enumeration
  • Next by thread: Re: fast enumeration
  • Index(es):
    • Date
    • Thread