检查coredata对象是否为nil [英] to check an coredata object is nil
本文介绍了检查coredata对象是否为nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想找出核心数据中的对象,我的代码:
I want to find out the objects in the core data, my code:
类型:
signedDate
(日期)
alarmDate
(日期)
starTime
(NSDate)
endTime
(NSDate)
NSString *str = @"(signedDate >= %@) AND (signedDate < %@) AND (alarmDate == nil)";
NSPredicate *predicate = [NSPredicate predicateWithFormat:str, starTime, endTime];
[request setPredicate:predicate];
NSArray *results=[context executeFetchRequest:request error:nil];
谓词错了吗?
如何判断coredata对象为nil?
谓词应该是什么?
predicate is wrong ? How to judge an coredata object is nil? What the predicate should be?
推荐答案
我认为谓词语法不需要== nil。
仅使用一个=
I don't think the predicate syntax calls for == nil. Use only one =
NSString *str = @"(signedDate >= %@) AND (signedDate < %@) AND (alarmDate = nil)";
上面的代码可以正常工作。
Your code above works right. It should be YES since it's nil.
BOOL ok;
predicate = [NSPredicate predicateWithFormat:@"firstName = nil"];
ok = [predicate evaluateWithObject:[NSDictionary dictionary]];
ok = [predicate evaluateWithObject:
[NSDictionary dictionaryWithObject:[NSNull null] forKey:@"firstName"]];
这篇关于检查coredata对象是否为nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文