I am trying to calculate the number of days from one date to another and have found two ways of doing so.
The first uses NSDateComponents as follows:
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [gregorianCalendar components:NSDayCalendarUnit
fromDate:date1
toDate:date2
options:0];
and then checking the [components day].
The second uses timeInterval:
NSInteger timeInterval = [date2 timeIntervalSinceDate:date1];
and then getting timeInterval/3600/24
Is one way better than the other (perhaps because of lack precision with the timeInterval methods)?
Thanks!