Re: Implementing NSFastEnumeration
"Adam R. Maxwell" <[email protected]>
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
On Oct 1, 2009, at 6:13 AM, Christiaan Hofman wrote: > I've been reading the documentation on NSFastEnumeration (both the > docs on the protocol and the section in the Objective-C 2.0 > Programming Language guide). But it is really cryptic and misses > most of the relevant information to help in implementing it. The Obj- > C 2.0 guide only mentions how to use it. And the NSFastEnumeration > doc only has some truly useless descriptions of its rather confusing > variables. For instance, saying that state->itemsPtr is "A C array > of objects" is about the most useless comment I've ever seen. I filed a doc bug on that a year and a half ago, asking for an implementation example. It was duped to rdar://problem/4895597. > And I've also not been able to find any (Apple) sample code that > implements this. Perhaps someone can give a link if he has found one? The documentation was worthless for implementing it. I used the CFArray source as a guide when implementing it for FVPriorityQueue, and it was extremely helpful to have a concrete example. > An important question I have is: which variable should eventually > hold the objects to return? As the NSFastEnumeration doc says that > stackbuf is "A C array of objects over which the sender is to > iterate", which would suggest that that's where the objects should > be returned. However I saw this blog at <http://cocoawithlove.com/2008/05/implementing-countbyenumeratingwithstat.html > > that has some samples that suggest that the real place to return > the objects is in state->itemsPtr. However from the docs I cannot > possibly get a clue what that variable is actually used for. IIRC this depends on whether you can return a pointer to internal storage directly, or need to copy them to a temporary C array. _______________________________________________ MacOSX-dev mailing list [email protected] http://www.omnigroup.com/mailman/listinfo/macosx-dev