我構建了以下謂詞以針對Core Data存儲使用MagicalRecord。爲什麼我得到「無法解析NSPredicate」錯誤
// format the date correctly
NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
[dateFormat setDateFormat:@"yyyy-MM-dd*"]; // HH:mm
NSString *formattedDate = [dateFormat stringFromDate:currentlySelectedDate];
NSString *stringPredicate = [NSMutableString stringWithFormat:
@"aPosX >= %f AND aPosX < %f AND %f > aPosY AND %f <= (aPosY + aPosH) AND aStartTime LIKE %@",
[staffIndex floatValue], [staffIndex floatValue] + 218, touchPoint.y, touchPoint.y, formattedDate];
NSPredicate *predicate = ([NSPredicate predicateWithFormat: stringPredicate]);
它崩潰的最後一條語句,此錯誤:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "aPosX >= 218.000000 AND aPosX < 436.000000 AND 15.000000 > aPosY AND 15.000000 <= (aPosY + aPosH) AND aStartTime LIKE 2013-05-09*"'
我都試過,我知道的一切,搜索谷歌和SO,仍然不明白爲什麼它的失敗...有人請賜教嗎?
謝謝......它不再崩潰,但謂詞不按我期望的方式工作......我有一個日期時間存儲在** astartTime **中,它看起來在看整個日期/時間。我只需要**日期**,而不是時間......我如何才能做到這一點? – SpokaneDude 2013-05-09 03:18:44
非常感謝你......那麼做了...... – SpokaneDude 2013-05-09 15:24:48