Created
May 23, 2011 02:09
-
-
Save rizumita/986108 to your computer and use it in GitHub Desktop.
NSString and NSNumber times repeat method like Ruby's times method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface NSString (Times) | |
- (void)times:(void (^)(void))block; | |
@end | |
@implementation NSString (Times) | |
- (void)times:(void (^)(void))block { | |
for (NSUInteger index = 0; index < [self longLongValue]; index++) { | |
block(); | |
} | |
} | |
@end | |
@interface NSNumber (Times) | |
- (void)times:(void (^)(void))block; | |
@end | |
@implementation NSNumber (Times) | |
- (void)times:(void (^)(void))block { | |
for (NSUInteger index = 0; index < [self longLongValue]; index++) { | |
block(); | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment