iphone:[NSNull getCharacters:]:使用NSPredicate无法识别的选择器错误 [英] iphone: [NSNull getCharacters:]: unrecognized selector error using NSPredicate

查看:423
本文介绍了iphone:[NSNull getCharacters:]:使用NSPredicate无法识别的选择器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在某些字段的核心数据中搜索实体时,我遇到以下错误:

  [NSNull getCharacters:]:无法识别的选择器发送到实例

这是我用来设置谓词的代码: p>

   - (void)filterContentForSearchText:(NSString *)searchText scope:(NSString *)scope 
{
NSPredicate * resultPredicate = [NSPredicate predicateWithFormat:@jobtitle =%@,@Barber];
searchResults = [getContacts filteredArrayUsingPredicate:resultPredicate];
}

但是,当我将谓词设置为其他字段,搜索工作正常:

   - (void)filterContentForSearchText:(NSString *)searchText scope:(NSString *)scope 
{
NSPredicate * resultPredicate = [NSPredicate predicateWithFormat:@title =%@,@Dr];
searchResults = [getContacts filteredArrayUsingPredicate:resultPredicate];
}

第一个版本在title字段/属性上搜索,第二个在jobtitle字段/



检查模型中的属性job和jobtitle,我不能区分它们之间的任何差异。



告诉我NSNull来自哪里,这是什么意思?



提前感谢任何建议。


<看起来像 getContacts 数组中的对象没有 jobtitle 属性在第一个方法。您可以通过打印第一个对象 NSLog(@%@,getContacts.firstObject)或打印整个数组 NSLog @,getContacts)


Hi when I try to search an entity in core data on certain fields, I get the following error:

[NSNull getCharacters:]: unrecognized selector sent to instance

This is code I am using to set predicate:

- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
    NSPredicate *resultPredicate =[NSPredicate predicateWithFormat:@"jobtitle=%@",@"Barber"];
    searchResults = [getContacts filteredArrayUsingPredicate:resultPredicate];
}

However, when I set the predicate to something I know is true on other fields, the search works correctly:

- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
    NSPredicate *resultPredicate =[NSPredicate predicateWithFormat:@"title=%@",@"Dr"];
    searchResults = [getContacts filteredArrayUsingPredicate:resultPredicate];
}

First version searches on title field/attribute, second on jobtitle field/attribute.

Examining the attributes job and jobtitle in the model, I cannot discern any difference between them.

Can anyone tell me where the NSNull is coming from and what it means? Could there be something I am missing in the properties of the attributes that would account for this?

Thanks in advance for any suggestions.

解决方案

Looks like objects in getContacts array don't have jobtitle property in first method. You can check it by printing the first object NSLog(@"%@", getContacts.firstObject) or print the whole array NSLog(@"%@", getContacts)

这篇关于iphone:[NSNull getCharacters:]:使用NSPredicate无法识别的选择器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆