0
我想使用謂詞來排序具有NSDate類型的日期屬性的對象的數組。但是,當我嘗試使用謂詞時,會引發異常,並且出現一個奇怪的錯誤。在NSArray上使用NSPredicate時崩潰
下面的代碼:
NSDate * minDate = [NSDate date];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date >= %@ ", minDate];
NSLog(@"%@",predicate);
NSArray * obs = [self.observations filteredArrayUsingPredicate:predicate];
這裏的錯誤:
2012-02-04 13:14:32.380 MyApp[42845:17303] date >= CAST(315558000.000000, "NSDate")
2012-02-04 13:14:32.381 MyApp[42845:17303] -[__NSDate length]: unrecognized selector sent to instance 0x9392f80
2012-02-04 13:14:32.381 MyApp[42845:17303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDate length]: unrecognized selector sent to instance 0x9392f80'
任何想法什麼我做錯了嗎?謝謝。
如果將其設置爲日期和月份組件的日期,會發生什麼情況? – vikingosegundo 2012-02-04 20:50:04
我將日期更改爲當前日期並得到相同的結果。 – 2012-02-04 21:15:42
你使用NSZombieEnabled工具嗎? – vikingosegundo 2012-02-04 21:22:01