Is there a way to directly access the internal dictionary of an external dictionary in Objective-C? For example, I have a key to an object that is part of an internal dictionary. Is there a way to directly access an object from this key.
GameDictionary { Indoor_Game = { "game1" = chess; "game2" = video_Game; "game3" = poker; }; OutDoor_Game = { "game4" = cricket; "game5" = hockey; "game6" = football; }; };
I have the key "game4", but I donβt know in which dictionary this key is present, at present I have to look in each dictionary for the object, the code that I use:
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; } }
Do they have a simple way of accessing directly to the internal dictionary, and not to loops.
Mayur source share