我构建了以下谓词以针对 Core Data 存储使用 MagicalRecord。
// 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]);
它在最后一条语句上崩溃,并出现以下错误:
*由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“无法解析格式字符串“aPosX >= 218.000000 AND aPosX < 436.000000 AND 15.000000 > aPosY AND 15.000000 <= (aPosY + aPosH) AND aStartTime LIKE 2013-05-09 *"'
我已经尝试了我所知道的一切,搜索了谷歌和 SO,但仍然不明白为什么它失败了......有人可以请教我吗?