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

Implementing fast enumeration


  • Subject: Implementing fast enumeration
  • From: Ben <email@hidden>
  • Date: Fri, 2 May 2008 20:18:13 +0100

Re-sending as this did not seem to get make it to the list.

I have been reading the documentation for implementing the NSFastEnumeration protocol and am having some difficulties following it.

For completeness, here is the protocol method:
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;


typedef struct {
unsigned long state;
id *itemsPtr;
unsigned long *mutationsPtr;
unsigned long extra[5]; } NSFastEnumerationState;

I have a C array where the elements within it can be converted into multiple objects. Say I have 5 objects. Do I provide them all in one go and return the total number? Or just one per call and return the number remaining?

Also, should the objects be returned by reference in the stackbuf variable, or in the itemsPtr field of the state structure?

Apologies if these are basic questions, but I got decidedly lost trying to follow the docs.

Ben.
_______________________________________________

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: Implementing fast enumeration
      • From: "Adam R. Maxwell" <email@hidden>
    • Re: Implementing fast enumeration
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Putting an Icon in the MenuBar
  • Next by Date: Re: Loading a .nib?
  • Previous by thread: Re: Putting an Icon in the MenuBar
  • Next by thread: Re: Implementing fast enumeration
  • Index(es):
    • Date
    • Thread