Try this instead:
NSTimeInterval timeInterval = [[NSDate date] timeIntervalSinceDate:groceryItem.lastPurchased];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%f", timeInterval];
A few points in this snippet:
- I used
NSTimeIntervalinstead doublein the second line. They are equivalent because it is just a typedef, but for a clearer code. - , ,
[NSDate date] groceryItem.lastPurchased. , groceryItem.lastPurchased . - ,
groceryItem.lastPurchased . , , , . , . , groceryItem.lastPurchasedDate, .