I want to find out the objects in the core data, my code:
Types:
signedDate
(Date)
alarmDate
(Date)
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];
predicate is wrong ? How to judge an coredata object is nil? What the predicate should be?
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"]];