NSPredicate for Dictionaries [英] NSPredicate for Array of Dictionaries
本文介绍了NSPredicate for Dictionaries的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个
Array
Item 0 -- Dictionary
Sport -- String
Mens -- Array
Item 0 -- Dictionary
Name -- String
Rules -- String
Description -- String
Womens -- Array
Item 0 -- Dictionary
Name -- String
Rules -- String
Description -- String
Item 1 -- Dictionary
And so on.....
我想创建一个NSPredicate搜索给定的字符串是否包含在Name中。我怎样才能达到那么深?
I would like to create a NSPredicate searching if a given string is contained inside of Name. How can I achieve reaching that deep?
如果你无法理解图表。我有一个充满字典的数组,里面的字典是一个字符串,一个字典数组和一个字典数组,里面的字典是字符串对象
If you cant understand the graph. I have an array full of dictionaries, Inside the dictionaries are A string, An Array of dictionaries, and An Array of dictionaries, Inside of the dictionaries are string objects
那么如何进入第二个词典并搜索名称密钥
So How do I get into the second dictionaries and search the Name key
提前致谢
推荐答案
您需要以下内容
NSString *str = <search string>;
NSPredicate *pred = [NSPredicate predicateWithFormat:@"ANY Mens.Name LIKE %@ OR ANY Womens.Name LIKE %@", str, str];
NSArray *result = [your_array filteredArrayUsingPredicate:pred];
BOOL success = result.count > 0;
这篇关于NSPredicate for Dictionaries的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文