こんにちは、以下のコードを使用していますが、null 値の startDate と endDate を取得しています。誰か助けてください
-(NSString *)datecomparison:(NSString *)STARTDATE forEndDate:(NSString *)ENDDATE{
NSLog(@"startDate:%@ endDate:%@",STARTDATE,ENDDATE);
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"dd-MM-yyyy"];
[df setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
NSDate *dt1 = [[NSDate alloc] init];
NSDate *dt2 = [[NSDate alloc] init];
dt1 = [df dateFromString:@"12/05/12"];
dt2 = [df dateFromString:@"13/05/12"];
NSLog(@"startDate:%@ endDate:%@",dt1,dt2);
NSComparisonResult result = [dt1 compare:dt2];
NSString *dateReturn = [[NSString alloc] init];
switch (result)
{
case NSOrderedAscending: NSLog(@"%@ is greater than %@", dt2, dt1);
dateReturn = @"ascending";
break;
case NSOrderedDescending: NSLog(@"%@ is less %@", dt2, dt1);
break;
case NSOrderedSame: NSLog(@"%@ is equal to %@", dt2, dt1);
dateReturn=@"ascending";
break;
default: NSLog(@"erorr dates %@, %@", dt2, dt1); break;
}
return dateReturn;
}