Mattt Thompson wrote a great post on NSHipster about the many ways to iterate with Objective-C.
The added value that enumerateObjectsUsingBlock
provides is giving the index of the object and NSEnumerationOptions
:
enum {
NSEnumerationConcurrent = (1UL << 0),
NSEnumerationReverse = (1UL << 1),
};
typedef NSUInteger NSEnumerationOptions;
Quoting Mattt:
Unless you actually need the numerical index while iterating, it's almost always faster to use a for/in NSFastEnumeration loop instead.
(...)
Again, fast enumeration is almost certain to be much faster than block enumeration, but these options may be useful if you're resigned to using blocks.