0
 +(int)weeksBetween:(NSDate *)startDate and:(NSDate *)endDate {

     NSInteger days = [[[NSCalendar currentCalendar] components: NSDayCalendarUnit fromDate: startDate toDate: endDate options: 0] day];

     return (days)/7;
 }

複数の方法components:fromDate:toDate:optionsQuestionに加えて、違いを計算してエラーを閉じることができるかどうかを確認しましたが、常に以下の同じ結果が得られます:

2013-09-16 08:24:52.268 app[9853:907] -[Day timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x1f589720

2013-09-16 08:24:52.270 app[9853:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Day timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x1f589720'

私の方法が言うように数週間が必要ですが、私が見たコードは一般的にその形式であるため、数日または数か月で実験してきました(同じ結果で数週間セレクターを使用しました)。

4

0 に答える 0