次のコードを使用して、生年月日の配列から残りの日数を取得したい
for(int i =0;i<_convertedBdates.count;i++){
NSDateFormatter *tempFormatter = [[NSDateFormatter alloc]init];
[tempFormatter setDateFormat:@"dd/MM/YYYY"];
NSDate *firstdate = [tempFormatter dateFromString:[_convertedBdates objectAtIndex:i]];
NSString *curYear = [tempFormatter stringFromDate:[NSDate date]];
NSDate *secondDate = [tempFormatter dateFromString:curYear];
NSTimeInterval lastDiff = [firstdate timeIntervalSinceNow];
NSTimeInterval todaysDiff = [secondDate timeIntervalSinceNow];
NSTimeInterval dateDiff = lastDiff - todaysDiff;
int day = dateDiff/(3600*24);
NSLog(@" _newlymadeArray %@",[_convertedBdates objectAtIndex:i]);
NSLog(@" days %d",day);
[_daysremaining addObject:[NSString stringWithFormat:@"%d",day] ];
}
NSLog(@" days %@",_daysremaining);
私は何を間違っているのか、なぜ私は正しい日を取得していないのですか