나 사이의 일의 차이를 얻으려고 오늘 [있는 NSDate 날짜]와 사용자가 UIDatePicker에서 선택하는 일, D, 윌 정수로서 돌려 주어집니다. 아이폰 OS -있는 NSDate/NSCalendar의 차이 일의 번호를 잘못 얻기
NSDate *startDate = d;
NSDate *endDate = [NSDate date];
NSLog(@"startDate: %@",startDate);
NSLog(@"endDate: %@",endDate);
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[gregorian setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
NSDateComponents *components = [gregorian components:NSDayCalendarUnit
fromDate:endDate
toDate:startDate
options:0];
NSInteger days = [components day];
NSLog(@"Days: %i",days);
두 의 startDate 및 endDate가
가 제대로 반환됩니다,하지만 내가 할 문제는 내가 할 일의 차이가 잘못입니다 :는 여기에 내가 그 차이를 알아 내기 위해 사용하고거야. 예를 들어 오늘 날짜를 선택하면 차이는 0입니다. 내일을 선택하면 차이는 여전히 0이고 그 다음 날을 선택할 때 차이는 1 일 때 2가되어야합니다.
누구든지이 문제를 해결하기 위해 할 수있는 것에 대한 아이디어가 있습니까? 그것은 나를 미치게 만들고있어. 나는 그 거래가 무엇인지 모르겠다.