Skip to content

Instantly share code, notes, and snippets.

@nhnam
Last active May 20, 2016 02:26
Show Gist options
  • Save nhnam/c178c5fd66c9cb40da45f8a8f3ed2320 to your computer and use it in GitHub Desktop.
Save nhnam/c178c5fd66c9cb40da45f8a8f3ed2320 to your computer and use it in GitHub Desktop.
// TODO: improve the loop
void standardlizeParams(NSMutableDictionary* defaultParams) {
NSMutableDictionary *mutableDict = [defaultParams mutableCopy];
for (NSString *key in [defaultParams allKeys]) {
if ([defaultParams[key] isEqual:[NSNull null]] || [defaultParams[key] isEqual:@""]) {
[mutableDict removeObjectForKey:key];
NSLog(@" ✕ %@", key);
}
else if([defaultParams[key] isKindOfClass:[NSDictionary class]]) {
standardlizeParams(defaultParams[key]);
}
}
defaultParams = [mutableDict copy];
}
void standardlizeArray(NSArray* array) {
for (int i = 0; i < array.count; i++) {
if([array[i] isKindOfClass:[NSArray class]]) {
standardlizeArray(array[i]);
} else if([array[i] isKindOfClass:[NSDictionary class]]) {
standardlizeParams(array[i]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment