Use the following code to do the convert from the nsstring to nsdate and compare them.
NSString *time1 = @"08:15:12";
NSString *time2 = @"18:12:08";
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"HH:mm:ss"];
NSDate *date1= [formatter dateFromString:time1];
NSDate *date2 = [formatter dateFromString:time2];
NSComparisonResult result = [date1 compare:date2];
if(result == NSOrderedDescending)
{
NSLog(@"date1 is later than date2");
}
else if(result == NSOrderedAscending)
{
NSLog(@"date2 is later than date1");
}
else
{
NSLog(@"date1 is equal to date2");
}