In my app I have an NSMutableArray that users can modify by adding or deleting entries from the array (btw entries are always added at index 0), this is done using a table view.
You can put the dates into an array and sort this array. Than you check, if the index of these different dates, to see, if one date lies between the others:
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *comps1 = [[NSDateComponents alloc] init];
NSDateComponents *comps2 = [[NSDateComponents alloc] init];
NSDateComponents *comps3 = [[NSDateComponents alloc] init];
[comps1 setDay:10];
[comps2 setDay:12];
[comps3 setDay:11];
NSDate *day1 = [gregorian dateByAddingComponents:comps1 toDate:[NSDate date] options:0];
NSDate *day2 = [gregorian dateByAddingComponents:comps2 toDate:[NSDate date] options:0];
NSDate *day3 = [gregorian dateByAddingComponents:comps3 toDate:[NSDate date] options:0];
NSMutableArray *array = [NSMutableArray arrayWithObjects:day1, day2, day3, nil];
[array sortUsingSelector:@selector(compare:)];
NSUInteger indexOfDay1 = [array indexOfObject:day1];
NSUInteger indexOfDay2 = [array indexOfObject:day2];
NSUInteger indexOfDay3 = [array indexOfObject:day3];
if (((indexOfDay1 < indexOfDay2 ) && (indexOfDay2 < indexOfDay3)) ||
((indexOfDay1 > indexOfDay2 ) && (indexOfDay2 > indexOfDay3))) {
NSLog(@"YES");
} else {
NSLog(@"NO");
}
[comps1 release];
[comps2 release];
[comps3 release];
[gregorian release];
NSDateComponents and NSCalendar let you do this kind of logic on NSDates.
If you have dates modeled in your app as strings, you will need to convert them to NSDates first. Better would be to model your dates as NSDates and use a formatter to turn them into strings for display in the table.