I have an iOS application which parses a JSON feed for data. In this data are some UNIX timestamps which I am storing in a NSString. What I want to do is to convert these timestamps into dates (month and day). But I am trying to do this without doing any division myself, because from what I have read online, you should always use Apple's API's to do the conversion for an accurate result.
However my code is not working and I get this error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance
Here is my code:
NSString *time_string = [timestamps objectAtIndex:indexPath.row];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd"];
NSDate *date = [formatter dateFromString:time_string];
cell.dateOfPub.text = [NSString stringWithFormat:@"%@", date];
I don't understand what I am doing wrong. Any help would be greatly appreciated.
Thanks, Dan