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

fast enumeration


  • Subject: fast enumeration
  • From: Boyd Collier <email@hidden>
  • Date: Sat, 27 Apr 2013 11:11:56 -0700

I have an array of NSStrings that in some circumstances,  I'd like to go through using fast enumeration starting with the second element in the array.  After a bit of fooling around, I came up with the following, which seems to work:

	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);
	}


But I worry that in my inexperience with fast enumeration I may have committed a sin that is likely to bite me later, or that what I've done is really less effective than using an old-fashioned loop.  Perhaps some of you have run bench-marks or come up with a more elegant way of doing this sort of thing.

Many thanks for your insights,
Boyd
_______________________________________________

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: Jens Alfke <email@hidden>
  • Prev by Date: Re: Can I determine who is calling a delegate
  • Next by Date: Re: fast enumeration
  • Previous by thread: Re: Can I determine who is calling a delegate
  • Next by thread: Re: fast enumeration
  • Index(es):
    • Date
    • Thread