I get datetime from server in double and when I convert it to date string in ios, I get error of EXEC_BAD_ACCESS from the first line of code below.
For example,
date string from server: 1426923003
This is how I convert it:
NSString *dateFromServer = [NSString stringWithFormat:@"%@" ,news.dateCreated];
NSLog(@"date server: %@",dateFromServer);
long long theDate = [dateFromServer longLongValue];
NSTimeInterval interval=theDate;
NSDate *datenew = [NSDate dateWithTimeIntervalSince1970:interval];
NSDateFormatter *_formatter=[[NSDateFormatter alloc]init];
[_formatter setLocale:[NSLocale currentLocale]];
[_formatter setDateFormat:@"dd-MM-yyyy hh:mm a"];
dateString=[_formatter stringFromDate:datenew];
I run this codes in method:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{}
in order to show date on each cell of tableview.
I don't know why it has error like this. How do we make work ? Thank you.