Reputation: 461
I have a NSString =@"KEY3";
and a NSMutableDictionary *AllValues ;
like the below . I just need to check whether the string is one of the element of the AllValues Dictionary
KEY1 {
MLCAvailable = "test";
MLCColorCode = "test2";
NotesCount = "test3";
},
KEY2 {
MLCAvailable = "test";
MLCColorCode = "test2";
NotesCount = "test3";
},
KEY3 {
MLCAvailable = "test";
MLCColorCode = "test2";
NotesCount = "test3";
},
KEY4 {
MLCAvailable = "test";
MLCColorCode = "test2";
NotesCount = "test3";
},
How should i find whether they KEY 3 is present in the given MutableDictionary ?
Upvotes: 0
Views: 42
Reputation: 355
You can find it with the help of for loop
for (NSString *strKey in [AllValues allKeys]) {
if ([strKey isEqualToString:@"KEY3"]) {
//your condition
}
}
Is it Helpfull?
Upvotes: 1
Reputation: 8501
You can just try and get the element...
if(AllValues[@"KEY3"]) {
//The element exists
}
Upvotes: 4