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

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

     return (days)/7;
 }

I have tried multiple ways components:fromDate:toDate:options and Question plus others to calculate the difference to see if I can close on the error but I always get the same result below:

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'

I would like weeks as my method says but I have been experimenting with days or months as the code I have seen is generally in that format (I have used the selector for weeks with the same result).

Community
  • 1
  • 1
Kevin
  • 3
  • 1
  • 1
    Are `startDate` and `endDate` actually `NSDate` instances? – Wain Sep 16 '13 at 14:56
  • 2
    Cause they sure *look* like they're instances of some class called `Day` from those errors. – ipmcc Sep 16 '13 at 14:58
  • The error message says that the class Day does not implement a method timeIntervalSinceReferenceDate. Please check this. – Reinhard Männer Sep 16 '13 at 15:07
  • I thought I was passing two NSDates but it turned out that one of them wasn't -> I was passing a Day object incorrectly when it should have been its date property. I appreciate the help - sorry my issue was so trivial. – Kevin Sep 16 '13 at 16:41

0 Answers0