Skip to content

Instantly share code, notes, and snippets.

@bencochran
Last active December 14, 2015 03:39
Show Gist options
  • Save bencochran/5022700 to your computer and use it in GitHub Desktop.
Save bencochran/5022700 to your computer and use it in GitHub Desktop.
@interface NSNumber (Enumeration)
- (void)times:(void (^)(NSUInteger index, BOOL *stop))block;
@end
@implementation NSNumber (Enumeration)
- (void)times:(void (^)(NSUInteger index, BOOL *stop))block
{
BOOL stop = NO;
for (NSUInteger index = 0; index < [self integerValue]; index++) {
block(index, &stop);
if (stop) break;
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment