+(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).