I have an NSMutableArray of Model objects.
Each Model Object has a startTime property of NSDate type
I would like to using NSPredicate to filter the NSMutableArray.
I want an array with items older then now and one with items newer then now.
This is the code im using but the filtered arrays are empty. I do make sure there are items in the primary array im filtering from.
NSPredicate *pastPredicate = [NSPredicate predicateWithFormat:@"(startTime < %@)", [NSDate date]];
NSPredicate *futurePredicate = [NSPredicate predicateWithFormat:@"(startTime >= %@)", [NSDate date]];
self.pastReservations = [self.reservations filteredArrayUsingPredicate:pastPredicate];
self.futureReservations = [self.reservations filteredArrayUsingPredicate:futurePredicate];
Can you guys let me know if you know what I’m doing wrong? I dont think I should have to use a block for predicate using a built in type.
My code was correct. There was code before that was not working right and self.reservations was empty like Ramy Al Zuhouri said.