Ios 如果使用NSPredicate或在NSPredicate内部,则无法成功筛选结果
我有一个NSArray&我正在尝试根据下面提到的查询筛选结果:Ios 如果使用NSPredicate或在NSPredicate内部,则无法成功筛选结果,ios,objective-c,nspredicate,Ios,Objective C,Nspredicate,我有一个NSArray&我正在尝试根据下面提到的查询筛选结果: self->filteredValues = [self->AllValues filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF.sku contains[cd]%@",text]]; 如果我单独使用SELF.sku或SELF.name,我可以成功筛选结果 问题是当我使用或在这样的查询之间进行查询时,我得到了崩溃结果:
self->filteredValues =
[self->AllValues filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF.sku contains[cd]%@",text]];
如果我单独使用SELF.sku或SELF.name,我可以成功筛选结果
问题是当我使用或在这样的查询之间进行查询时,我得到了崩溃结果:
self->filteredValues =
[self->AllValues filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(SELF.sku contains[cd]%@) OR (SELF.name contains[cd]%@)",text]];
错误:2018-06-05 12:39:55.137706+0530 AppName[43371:14206450]***
由于未捕获异常而终止应用程序
'NSInvalidArgumentException',原因:'无法查找值
()串(24”高贵花环(6));
值不是字符串的
如何解决此问题。谓词中缺少第二个参数
self->filteredValues =
[self->AllValues filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(SELF.sku contains[cd]%@) OR (SELF.name contains[cd]%@)",text, <#second argument#>]];
self->filteredvalue=
[self->AllValues FilteredArrayingPredicate:[NSPredicate predicateWithFormat:@](self.sku包含[cd]@)或(self.name包含[cd]@),text,];
在谓词中设置
。谓词中缺少第二个参数
self->filteredValues =
[self->AllValues filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(SELF.sku contains[cd]%@) OR (SELF.name contains[cd]%@)",text, <#second argument#>]];
self->filteredvalue=
[self->AllValues FilteredArrayingPredicate:[NSPredicate predicateWithFormat:@](self.sku包含[cd]@)或(self.name包含[cd]@),text,];
在谓词中设置
。检查谓词的格式字符串。您有两个%@
占位符,但只有一个参数提供值
self->filteredValues =
[self->AllValues filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(SELF.sku contains[cd]%@) OR (SELF.name contains[cd]%@)",text, <#second argument#>]];
我打赌这会解决问题:
[NSPredicate predicateWithFormat:@"(SELF.sku contains[cd]%@) OR (SELF.name contains[cd]%@)", text, text]
检查谓词的格式字符串。您有两个
%@
占位符,但只有一个参数提供值
我打赌这会解决问题:
[NSPredicate predicateWithFormat:@"(SELF.sku contains[cd]%@) OR (SELF.name contains[cd]%@)", text, text]