Objective c 在创建谓词时获取SIGABRT

Objective c 在创建谓词时获取SIGABRT,objective-c,ios,Objective C,Ios,在我的应用程序中,我使用NSPredicate过滤一个数组,该数组中填充了来自iPhone通讯录的数据 对于数组中的每个人,我都会得到firstName,lastName,email和昵称, 然后我根据搜索字符串过滤数组 我为该搜索字符串创建了一个谓词,但由于某种原因,我无法理解,我的应用程序正在崩溃 我不熟悉谓词,不知道哪里出了问题,我的代码使用“contains”而不是“beginswith”运行得很好 下面是使我的应用程序崩溃的代码片段 NSPredicate *filterPredica

在我的应用程序中,我使用
NSPredicate
过滤一个数组,该数组中填充了来自iPhone通讯录的数据

对于数组中的每个人,我都会得到
firstName
lastName
email
昵称
, 然后我根据搜索字符串过滤数组

我为该
搜索字符串创建了一个谓词,但由于某种原因,我无法理解,我的应用程序正在崩溃

我不熟悉谓词,不知道哪里出了问题,我的代码使用“contains”而不是“beginswith”运行得很好

下面是使我的应用程序崩溃的代码片段

NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:
                                            @"(firstName beginswith[cd] %@) OR (lastName beginswith[cd] %@) OR (nickName beginswith[cd] %@) OR (email beginswith[cd] %@)",
                                            searchTextComponent,searchTextComponent,searchTextComponent];
您有4个“%@”,只有3个参数

NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:
                                            @"(firstName beginswith[cd] %@) OR (lastName beginswith[cd] %@) OR (nickName beginswith[cd] %@) OR (email beginswith[cd] %@)",
                                            searchTextComponent,searchTextComponent,searchTextComponent, SEARCHTEXTCOMPONENT ONE MORE TIME];

谢谢,我真是太蠢了,顺便说一句,我需要把这些字符串放在单引号里吗?例如:“@”不再崩溃,但我的筛选数组显示为零元素。总之,我的问题解决了,感谢您的初步帮助。对不起,我不能说我自己对使用谓词了解很多。我只是注意到了遗漏的论点。我只使用过一次谓词,我用过%@(没有单引号)。是的..我意识到,我用的是引号,这就是数组中没有匹配的原因。