Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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 如何在.plist中查找特定值,然后检索匹配项_Ios_Objective C_Plist - Fatal编程技术网

Ios 如何在.plist中查找特定值,然后检索匹配项

Ios 如何在.plist中查找特定值,然后检索匹配项,ios,objective-c,plist,Ios,Objective C,Plist,正如标题所示,我的.plist文件是这种格式的-我不知道如何标记它以便您阅读。Stackoverflow不理解格式 root (array) Item 0 - Dict numberOfPerson String recipeName String recipeIngredients String Item 1 -Dict Num

正如标题所示,我的.plist文件是这种格式的-我不知道如何标记它以便您阅读。Stackoverflow不理解格式

root (array)
         Item 0 - Dict
                numberOfPerson String
                recipeName  String
                recipeIngredients String
          Item 1 -Dict
                NumberOfPerson String
...
我有一个用户文本字段,用户将输入几个字符串

我想查找每个项目的输入和接收元素的匹配项

当找到它时,我想转到我实现的tableview中的单元格

我怎样才能做到这一点

这些就是我迄今为止所尝试的

NSString *path = [[NSBundle mainBundle] pathForResource:@"recipes" ofType:@"plist"];
NSArray *arrayOfPlist = [[NSArray alloc] initWithContentsOfFile:path];
结果证明这没用,我不能用objectForKey

 for (int i=0; i<2; i++) {

           recipeIngredientsArray = [[arrayOfPlist objectAtIndex:i]                      objectForKey:@"recipeIngredients"];

}
这对我也没有帮助,我无法保持良好的isequl方法


谢谢您的帮助。

您有一系列要筛选的词典。查看如何使用indexesOfObjectsPassingTest:。在数组上运行此操作,并测试传递的字典以检查RecipeIngElements值的值

然后可以使用索引查看是否有匹配项并显示它们。或者,您可以使用filteredArrayUsingPredicate:直接过滤数组:

NSArray *results = [arrayOfPlist filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"recipeIngredients CONTAINS[cd] %@", input]];

然后在表视图中仅显示筛选的结果。

afaict。。。NSString*strCurrentRecipeName=[[arrayOfPlist对象索引:i]objectForKey:@recipeName];我会给你回信的我知道这并不能真正回答问题。。。哪一个这就是为什么它是一个commentrecipeIngredientsArray=[[ArrayOfList objectAtIndex:i]没有意义,因为索引i上的对象是一个字典,而不是数组。@马特:好吧,我设法用这个小循环得到了所有的食谱成分。以后不能用它,但它有意义,伙计,这是什么东西。你确定那些花括号和其他的东西吗?很可能我在浏览器中键入的语法错误。让我看看eck块语法…缺少块返回类型。
NSArray *results = [arrayOfPlist filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"recipeIngredients CONTAINS[cd] %@", input]];