Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.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 具有两个字符串的字典的筛选器数组_Ios_Objective C_Json_Nspredicate - Fatal编程技术网

Ios 具有两个字符串的字典的筛选器数组

Ios 具有两个字符串的字典的筛选器数组,ios,objective-c,json,nspredicate,Ios,Objective C,Json,Nspredicate,对于搜索下拉表,我需要分别在cell textlabel和detailed textlabel中显示“描述”和“搜索词”。我需要实现基于两个字符串的过滤器,即搜索文本应该和“描述”和“搜索词”进行比较。我尝试了NSPredicate,但它只能筛选一个字符串 NSString *substring = [NSString stringWithString:searchServiceTextField.text]; NSLog(@"substring %@",substring); NSMutabl

对于搜索下拉表,我需要分别在cell textlabel和detailed textlabel中显示“描述”和“搜索词”。我需要实现基于两个字符串的过滤器,即搜索文本应该和“描述”和“搜索词”进行比较。我尝试了NSPredicate,但它只能筛选一个字符串

NSString *substring = [NSString stringWithString:searchServiceTextField.text];
NSLog(@"substring %@",substring);
NSMutableArray *arr2Filt= [searchArray valueForKey:@"Description"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF  contains[c] %@",substring];
NSArray *filteredarr = [NSMutableArray arrayWithArray:[arr2Filt filteredArrayUsingPredicate:predicate]];
NSLog(@"filtered array %@",filteredarr);
我试图修改两个字符串,但没有得到更好的解

  [{
        Description = "Rental Jewellery, Jewellery for events";
        ProfessionId = "<null>";
        SKUFormat = "<null>";
        SearchTerms = "Rental Jewellery";
        SpecialityId = 62;
        tokens = "<null>";
        value = "<null>";
    },
    {
        Description = "Kids Party with Food and Games Venues";
        ProfessionId = "<null>";
        SKUFormat = "<null>";
        SearchTerms = "Party Venue";
        SpecialityId = 63;
        tokens = "<null>";
        value = "<null>";
    },
    {
        Description = "Music, Dance, Sports classes";
        ProfessionId = "<null>";
        SKUFormat = "<null>";
        SearchTerms = Classes;
        SpecialityId = 64;
        tokens = "<null>";
        value = "<null>";
    },
    {
        Description = "Zumba, Yoga, Aerobics classes";
        ProfessionId = "<null>";
        SKUFormat = "<null>";
        SearchTerms = "Fitness/Health";
        SpecialityId = 65;
        tokens = "<null>";
        value = "<null>";
    }
    ]
[{
Description=“租赁珠宝、活动珠宝”;
ProfessionId=“”;
sku格式=”;
SearchTerms=“租赁珠宝”;
特殊性id=62;
代币=”;
value=“”;
},
{
Description=“有食物和游戏场地的儿童派对”;
ProfessionId=“”;
sku格式=”;
SearchTerms=“派对地点”;
特殊性id=63;
代币=”;
value=“”;
},
{
Description=“音乐、舞蹈、体育课”;
ProfessionId=“”;
sku格式=”;
SearchTerms=类;
SpecialityId=64;
代币=”;
value=“”;
},
{
Description=“尊巴、瑜伽、健美操课程”;
ProfessionId=“”;
sku格式=”;
SearchTerms=“健身/健康”;
特殊性ID=65;
代币=”;
value=“”;
}
]
你可以这样做

NSString *substring = [NSString stringWithString:searchServiceTextField.text];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"Description contains[c] %@ AND SearchTerms contains[c] %@",substring, substring];
NSArray * filteredarr =[[searchArray filteredArrayUsingPredicate:predicate] copy];

NSLog(@"filtered array %@",filteredarr);