我想找出核心数据中的对象,我的代码:
类型:
signedDate(Date)
alarmDate(日期)
STARTIME(NSDate的)
结束时间(的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.
只使用一个=
只使用一个=
NSString *str = @"(signedDate >= %@) AND (signedDate < %@) AND (alarmDate = nil)";
你以上的代码正确.如果应该是YES,因为它是零.
BOOL ok; predicate = [NSPredicate predicateWithFormat:@"firstName = nil"]; ok = [predicate evaluateWithObject:[NSDictionary dictionary]]; ok = [predicate evaluateWithObject: [NSDictionary dictionaryWithObject:[NSNull null] forKey:@"firstName"]];