NSDateComponents sur IOS6 ne fonctionne pas?

J'ai un programme simple qui fonctionnait avec IOS4 et 5. Maintenant avec IOS 6 j'obtiens le message d'erreur suivant:

2012-10-05 11:08:16.386 app[1698:19d03] 2012-10-05 09:08:11 +0000 2012-10-05 11:08:18.072 app[1698:19d03] 2012-10-05 09:08:11 +0000 2012-10-05 11:08:19.273 app[1698:19d03] 2012-10-05 09:08:11 +0000 2012-10-05 11:08:19.274 app[1698:19d03] 2012-10-05 09:08:11 +0000 2012-10-05 11:08:19.275 app[1698:19d03] 0 2012-10-05 11:08:25.055 app[1698:19d03] 2011-10-05 09:08:11 +0000 2012-10-05 11:08:25.823 app[1698:19d03] ( "<UILongPressGestureRecognizer: 0xa167f60; state = Possible; view = <UITableViewCellContentView 0xa168000>; target= <(action=_longPressGestureRecognized:, target=<UIPickerTableViewWrapperCell 0xa168090>)>>") 2012-10-05 11:08:25.824 app[1698:19d03] 2012-10-05 09:08:11 +0000 2012-10-05 11:08:25.824 app[1698:19d03] -[__NSArrayI timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x94ef5d0 2012-10-05 11:08:25.825 app[1698:19d03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x94ef5d0' *** First throw call stack: (0x1d16012 0x11fae7e 0x1da14bd 0x1d05bbc 0x1d0594e 0x1d25cd3 0xa092 0x120e705 0x145920 0x1458b8 0x206671 0x206bcf 0x205d38 0x17533f 0x175552 0x1533aa 0x144cf8 0x1f4fdf9 0x1f4fad0 0x1c8bbf5 0x1c8b962 0x1cbcbb6 0x1cbbf44 0x1cbbe1b 0x1f4e7e3 0x1f4e668 0x14265c 0x296d 0x28a5) 

Le premier passage est avec deux dates qui sont égales. En deuxième manche, j'ai changé le fhDate sur le sélecteur comme vous pouvez le voir …

Le code est simplifié un peu pour une lecture plus facile:

 aiDate = [adoIgazPicker date]; NSLog(@"%@", aiDate); fhDate = [forgHelyPicker date]; NSLog(@"%@", fhDate); NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar]; NSDate *startDate = fhDate; NSDate *endDate = aiDate; NSLog(@"%@", startDate); NSLog(@"%@", endDate); NSDateComponents *comps = [gregorian components:NSMonthCalendarUnit fromDate:startDate toDate:endDate options:0]; //THIS LINE FAILS IF THE DATES ARE NOT THE SAME int months = [comps month]; NSLog(@"%i", months); 

Merci de votre aide!

J'ai remplacé

 NSDateComponents *comps = [gregorian components:NSMonthCalendarUnit fromDate:startDate toDate:endDate options:0]; 

avec

 NSInteger months = [[[NSCalendar currentCalendar] components: NSMonthCalendarUnit fromDate: startDate toDate: endDate options: 0] month]; 

et maintenant ça marche :).