Background:
a Object:
MyObject : NSObject
@property NSInteger type;
a NSDictionary:
@{
@"1":@{@"1":MyObject}
@"2":@{@"1":MyObject}
}
Now,got a MyObject and it's type=1; how to make sure whether this MyObject contained in the NSDictionary?
Background:
a Object:
MyObject : NSObject
@property NSInteger type;
a NSDictionary:
@{
@"1":@{@"1":MyObject}
@"2":@{@"1":MyObject}
}
Now,got a MyObject and it's type=1; how to make sure whether this MyObject contained in the NSDictionary?
I'm taking into consideration, that your dictionary only has one key/pair and there are no similar key names present
NSDictionary *dict = @{ @"a":@{@"c":@"MyObject"} ,@"b":@{@"d":@"MyObject"} } ;
NSMutableArray *valuesArray = [[NSMutableArray alloc]init];
// enumerate and add all values to our value array
[dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
NSLog(@"Your value : %@", [obj description]);
[valuesArray addObject:[[obj allValues] firstObject]];
}];
// check whether this value is present
if ([valuesArray containsObject:@"MyObject"]) {
NSLog(@"My Object found",);
}