Created
January 9, 2013 15:10
-
-
Save dnnta/4493852 to your computer and use it in GitHub Desktop.
Compare two NSDictionary
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
-(BOOL)isEtalonDictionary:(NSDictionary *)etalonDictionary sameAs:(NSDictionary *)dictionary{ | |
BOOL res = NO; | |
for (id item in etalonDictionary){ | |
NSObject *secondObject = [dictionary objectForKey:item]; | |
if (secondObject == nil) | |
return NO; | |
else{ | |
NSObject *value = [etalonDictionary objectForKey:item]; | |
if ([value isKindOfClass:[NSString class]]){ | |
NSString *string = (NSString *) value; | |
if ([string isEqualToString:(NSString *) secondObject]){ | |
res = YES; | |
} else { | |
return NO; | |
} | |
} | |
if ([value isKindOfClass:[NSNumber class]]){ | |
NSNumber *number = (NSNumber *) value; | |
if([number isEqualToNumber:(NSNumber *) secondObject]) | |
res = YES; | |
else | |
return NO; | |
} | |
if ([value isKindOfClass:[NSDictionary class]]){ | |
res = [self isEtalonDictionary:(NSDictionary *) value sameAs:(NSDictionary *) secondObject]; | |
if (!res){ | |
return NO; | |
} | |
} | |
} | |
} | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment