Example of filtering an array using predicateWithBlock
Copy this code and paste it in your HTML
[dateFormatter setDateFormat:@"dd/mm/yyyy"];
NSDate *referenceDate
= [dateFormatter dateFromString
:@"16/08/2010"];
NSArray *otherDates
= [NSArray arrayWithObjects
:@"12/08/2010",
@"25/10/1990",
@"30/08/2010",
@"25/12/2010",
nil];
return [referenceDate earlierDate
: [dateFormatter dateFromString
: (NSString *)obj
]] == referenceDate;
}];
NSArray *futureDates
= [otherDates filteredArrayUsingPredicate
: findFutureDates
];
[dateFormatter release];
Report this snippet
Comments
Subscribe to comments