Pregunta

I have an NSMutableDictionary that loads data from a certain source.

  • He is loading fine and while debugging i am sure he is loading and that in the end he has the exact number of elements. I also can see the elements as they should while debugging.

  • I just want to get the value of the the row having the key value = 3 .

I tried NSString * myString = [myMutabDict objectForKey:@"3"], considering that the value is in string ,and i followed it with the debugger, and i am sure that my NSDictionary has elements in it , and i can see them while debugging, and i can see the key 3 , but i still get null as an output

What am i missing?

¿Fue útil?

Solución

If you are sure you see a value with a key of 3 and you can't load it using the key @"3" then it is possible that the key is a number. Use:

NSString *myString = [myMutableDict objectForKey:@3];

or modern syntax:

NSString *myString = myMutableDict[@3];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top