Skip to content

Instantly share code, notes, and snippets.

@sstadelman
Created June 5, 2014 23:16
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 sstadelman/f29c983c14668e5767eb to your computer and use it in GitHub Desktop.
Save sstadelman/f29c983c14668e5767eb to your computer and use it in GitHub Desktop.
block declaration pattern
NSDictionary* (^SetODataTypesInDictionary)(NSDictionary *dictionary) = ^NSDictionary* (NSDictionary *inputDict) {
NSMutableDictionary *mutableObj = [NSMutableDictionary dictionaryWithDictionary:inputDict];
NSArray *allKeys = [mutableObj allKeys];
[allKeys enumerateObjectsUsingBlock:^(NSString *key, NSUInteger idx, BOOL *stop) {
NSObject *propValue = [(id<SODataProperty>)[mutableObj objectForKey:key] value];
if ([propValue isKindOfClass:[NSDictionary class]]) {
propValue = SetODataTypesInDictionary((NSDictionary *)propValue);
}
[mutableObj setValue:propValue forKey:key];
}];
return [NSDictionary dictionaryWithDictionary:mutableObj];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment