Ios 如何查找NSMutableDictionary中是否存在给定字符串
我有一个Ios 如何查找NSMutableDictionary中是否存在给定字符串,ios,objective-c,xcode,nsmutabledictionary,Ios,Objective C,Xcode,Nsmutabledictionary,我有一个NSString=@“KEY3”和NSMutableDictionary*所有值如下所示。我只需要检查字符串是否是AllValues字典的元素之一 KEY1 { MLCAvailable = "test"; MLCColorCode = "test2"; NotesCount = "test3"; }, KEY2 { MLCAvailable = "test"; MLCColorCode = "test2"; NotesCou
NSString=@“KEY3”代码>和NSMutableDictionary*所有值代码>如下所示。我只需要检查字符串是否是AllValues字典的元素之一
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 ?
您可以尝试获取元素
if(AllValues[@"KEY3"]) {
//The element exists
}
您可以尝试获取元素
if(AllValues[@"KEY3"]) {
//The element exists
}
您可以在for循环的帮助下找到它
for (NSString *strKey in [AllValues allKeys]) {
if ([strKey isEqualToString:@"KEY3"]) {
//your condition
}
}
它是否有用?您可以在for循环的帮助下找到它
for (NSString *strKey in [AllValues allKeys]) {
if ([strKey isEqualToString:@"KEY3"]) {
//your condition
}
}
它是否有用?if([AllValues objectForKey:@“KEY3”]){NSLog(@“YES”);}if([AllValues objectForKey:@“KEY3”]){NSLog(@“YES”);}