Skip to content

Instantly share code, notes, and snippets.

@ddribin
Created July 5, 2009 23:42
Show Gist options
  • Save ddribin/141181 to your computer and use it in GitHub Desktop.
Save ddribin/141181 to your computer and use it in GitHub Desktop.
#define DDFOREACH(_ARRAY_, _BLOCK_) { \
[_ARRAY_ enumerateObjectsUsingBlock:^(id object, NSUInteger idx, BOOL *stop) { \
_BLOCK_(object); \
}]; \
}
#define ddbreak *stop = YES; return;
void doForeach(void)
{
NSArray * colors = [NSArray arrayWithObjects:@"Red", @"Green", @"Blue", nil];
DDFOREACH(colors, ^(NSString * color){
NSLog(@"Color: %@", color);
if ([color length] == 5)
ddbreak;
NSLog(@"Done");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment