Suppose I have a class Event, and it has 2 properties: action (NSString) and date (NSDate).
And suppose I have an array of Event objects. The problem is that \"date\" pr
You can create an NSMutableSet
of dates, iterate your event list, and add only events the date for which you have not encountered before.
NSMutableSet *seenDates = [NSMutableSet set];
NSPredicate *dupDatesPred = [NSPredicate predicateWithBlock: ^BOOL(id obj, NSDictionary *bind) {
Event *e = (Event*)obj;
BOOL seen = [seenDates containsObject:e.date];
if (!seen) {
[seenDates addObject:e.date];
}
return !seen;
}];
NSArray *events = ... // This is your array which needs to be filtered
NSArray *filtered = [events filteredArrayUsingPredicate:dupDatesPred];