CoreData NSPredicate date()函数
我试图使用下面的谓词:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ending_date < date('now')", nil];
但我得到NSInvalidArgumentException', reason: 'Unable to parse function name 'date:' into supported selector (date:) '
所以我想也许date('now')
不支持iOS版本的SQLite
我怎么能做到这一点?
你可以试试这个…
NSDate *dateNow = [NSDate date]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ending_date < %@", dateNow];
你应该使用NSExpression而不是date:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ending_date < now", nil];