Elias Rahme
Elias Rahme

Reputation: 2227

Access one specific element of NSMutableDictionary getting null values in iOS

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

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?

Upvotes: 0

Views: 57

Answers (1)

rmaddy
rmaddy

Reputation: 318774

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];

Upvotes: 3

Related Questions