IOS: catch an information in a NSDictionary
I have an开发者_Go百科 NSArray and in the first position in this array there is a NSDictionary. In this dictionary there is two values: first value have a key "name" and second value have a key "number". If I know value of "name" can I get value of "number"?
So, you're looking to find the key in a dictionary when you only know the value.
For example, you have a dictionary where "a" => "4" and "b" => "3", the following code:
NSArray* matchingKeys = [dictionary allKeysForObject:@"3"];
Would return an array with "b" as the only element.
I solved in this way:
for (int j = 0; j<array.count; j++)
{
NSArray *listaDictionary = [array objectAtIndex:j];
for(int x=0;x<listaDictionary.count;x++)
{
if([[[listaDictionary objectAtIndex:x] objectForKey:@"number"]intValue] == myNumber)
精彩评论