2014-09-03 49 views
0

我嘗試使用下面的謂詞: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

我該如何實現它?

回答

1

你可以試試這個...

NSDate *dateNow = [NSDate date]; 
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ending_date < %@", dateNow]; 
0

現在,你應該使用,而不是日期的NSExpression:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ending_date < now", nil];