Created
March 12, 2012 12:39
-
-
Save finestructure/2021560 to your computer and use it in GitHub Desktop.
Globals initializer
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
- (id)init { | |
self = [super init]; | |
if (self) { | |
valuesSerialQueue = dispatch_queue_create("de.abstracture.valuesSerialQueue", NULL); | |
self.values = [NSMutableDictionary dictionary]; | |
[[NSArray arrayWithObjects: | |
@"A", @"B", @"C", @"D", @"E", @"F", nil] | |
enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
NSString *value = [self slowInitForKey:obj]; | |
dispatch_async(valuesSerialQueue, ^{ | |
[self.values setObject:value forKey:obj]; | |
}); | |
}); | |
}]; | |
} | |
return self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment