• 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: Boyd Collier <email@hidden>
  • Date: Sat, 27 Apr 2013 14:20:08 -0700

Excellent!  Thanks very much for pointing this out.

Boyd


On Apr 27, 2013, at 11:21 AM, Jens Alfke wrote:

>
> 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


References: 
 >fast enumeration (From: Boyd Collier <email@hidden>)
 >Re: fast enumeration (From: Jens Alfke <email@hidden>)

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