you look sane © 2007, 2008 Rob Rix

forall Macro

Obsolete as of Leopard and Objective-C 2.0, this macro by Allan Odgaard:

#ifndef forall
#define forall(collection, element) \
  for( \
    id _enumerator = [collection objectEnumerator], \
    element; \
    element = [_enumerator nextObject];)
#endif

lets you quickly enumerate any Cocoa collection that responds to -objectEnumerator with a simple forall(collection, element) { … } statement.

Nowadays you should be using Objective-C 2.0’s fast enumeration instead.