Last active
May 20, 2016 02:26
-
-
Save nhnam/c178c5fd66c9cb40da45f8a8f3ed2320 to your computer and use it in GitHub Desktop.
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
// 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