在我的 iOS 应用程序中,我拉入 JSON,并将其设置为一个数组。数组如下所示:
links = {
"link_1" = {
clicks = 1;
ip = "10.0.0.0";
shorturl = "http://on.example.com/abc";
timestamp = "2013-10-30 05:56:51";
title = Example Website;
url = "http://example.com/page/1/path/";
};
"link_2" = {
clicks = 10;
ip = "10.0.0.0";
shorturl = "http://on.example.com/def";
timestamp = "2013-10-16 16:55:47";
title = "Fitbit Force Is the Smartest Fitness Tracker Yet [REVIEW]";
url = "http://mashable.com/2013/10/16/fitbit-force-review/";
};
我设置了以下方法来过滤UITableView
结果:
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
NSPredicate *resultPredicate = [NSPredicate
predicateWithFormat:@"links.link_1.title contains[cd] %@",
searchText];
searchResults = [filterArray filteredArrayUsingPredicate:resultPredicate];
}
我需要更新predicateWithFormat
过滤器以说明link_1
, link_2
, link_3
,...
问题:如何让过滤器匹配数组的任何“级别”,其中后面的字符串link_
始终是正数,但可以是无限位数?
link_
对于每个正数,我基本上需要在级别上搜索数组。