Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View NSString+ConcurrentEnumeration.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#import "NSString+ConcurrentEnumeration.h"
 
@implementation NSString (ConcurrentLineEnumeration)
 
- (void)enumerateConcurrentlyWithOptions:(NSStringEnumerationOptions)options
usingBlock:(void (^)(NSString *substring))block
{
dispatch_group_t group = dispatch_group_create();
[self enumerateSubstringsInRange:NSMakeRange(0, [self length])
options:options
usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclRange, BOOL *stop)
{
dispatch_group_async(group, dispatch_get_global_queue(0, 0), ^ {
block(substring);
});
}];
dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
}
 
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.