NSDate * date = [NSDate date];
NSArray * array = @[];
NSUInteger index =
[array indexOfObjectPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
return ![[((NSDate *)obj) earlierDate:date] isEqualToDate:date];
}];
NSDate * refDate = nil;
if (index != NSNotFound)
refDate = array[index];