I’m using the following method to determine the number of days between two NSDate’s :
- (int)daysBetweenDate:(NSDate *)start andDate:(NSDate *)end {
NSTimeInterval lastDiff = [start timeIntervalSinceNow];
NSTimeInterval todaysDiff = [end timeIntervalSinceNow];
NSTimeInterval dateDiff = lastDiff - todaysDiff;
double numOfDays = dateDiff/86400; //86400 seconds in a day
return (int)(numOfDays + 0.5);
}
And I’m calling it like this:
int numOfDays = [self daysBetweenDate:lastResetDay andDate:[dict objectForKey:@"nsDate"]];
Both values I’m passing in are NSDate’s
The above is called while enumerating through an NSMutableArray.
And after running this I’m getting the following error:
Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[UITableView timeIntervalSinceNow]: unrecognized selector sent to instance 0x6818600’
At some point you’re storing a
UITableViewin something intended to be anNSDate. Debug through your code and check the values in the array, and along the way, and see where you’re doing this. ObjC is weakly typed, and an it’s easy to put the wrong type into anNSMutableArraybecause it takes and returnsid.