Is there a way to directly access an inner-Dictionary of an outer Dictionary in Objective-C? For example, I have key to an object which is part of inner dictionary, Is there any way to directly access object from that key.
GameDictionary {
Indoor_Game = { "game1" = chess; "game2" = video_Game; "game3" = poker; };
OutDoor_Game = { "game4" = cricket; "game5" = hockey; "game6" = football; };
};
I have a key "game4", but I don't know in which dictionary object of this key is present, currently I have to search in each dictionary for object, the code which I am using is:
NSString* gameName = nil;
NSString* gameKey = @"game4";
NSArray* gameKeys = [GameDictionary allKeys];
for (int index = 0; index < [gameKeys count]; index ++) {
NSDictionary* GameType = [GameDictionary objectForKey:[gameKeys objectAtIndex:index]];
if ([GameType objectForKey:gameKey]) {
gameName = [GameType objectForKey:gameKey];
break;
}
}
Is their any easy way to access directly to the inner dictionary instead of for loops.