Skip to content

Instantly share code, notes, and snippets.

@finestructure
Created March 12, 2012 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save finestructure/2021560 to your computer and use it in GitHub Desktop.
Save finestructure/2021560 to your computer and use it in GitHub Desktop.
Globals initializer
- (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