My application is an expense list that has entity like this:
Expense:
date [NSDate]
location [NSString]
name [NSString]
price [float]
I’ld like to show the expenses on UITableView group into section by month and later by date of month in another table view (drill down design). NSDate itself includes time so, the results that are filtered by date will also filter by time.
I’ve try:
NSPredicate *chooseDateAt = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
Expense *expense = (Expense *)evaluatedObject;
return expense.dateWithoutTime == preferedDateWithoutTime;
}];
But it has this error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unknown predicate type for predicate: BLOCKPREDICATE(0x12048)'
And I can’t see the other ways to work it out without using predicateWithBlock, can anyone help?
1) Determine the start of the day (0:00 on the same day) –>
startDate2) Form the predicate like this:
Actually, it has been pointed out that one should not use the seconds to add one day as I have done in
dateByAddingTimeInterval. Better to use this as the end date: