Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何查找NSMutableDictionary中是否存在给定字符串_Ios_Objective C_Xcode_Nsmutabledictionary - Fatal编程技术网

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”);}