开发者

error after calling TimeIntervalSinceNow on an NSDate?

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 开发者_Go百科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 UITableView in something intended to be an NSDate. 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 an NSMutableArray because it takes and returns id.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜