Here is my code, please help. In the below I need to get the time taken to load image from url and display the time in custom tableview cell. Which we can use either NSTimer or NSDate.
Thanks in advance.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCell";
TableViewCell *cell = (TableViewCell *)[_tableViewUsername dequeueReusableCellWithIdentifier:CellIdentifier];
NSDate *object = arrURL[indexPath.row];
rowCount = indexPath.row;
cell.userName.text = [arrUserNames objectAtIndex:indexPath.row];
if ([object valueForKey:@"status"])
{
if([[object valueForKey:@"status"]isEqualToString:@"completed"] && [object valueForKey: @"image"] && [[object valueForKey: @"image"] isKindOfClass:[UIImage class]])
{
cell.customImageView.contentMode = UIViewContentModeScaleToFill;
cell.customImageView.image = [object valueForKey:@"image" ];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}
else
{
[object setValue:@"inprogress" forKey:@"status"];
[self.operationQueue addOperationWithBlock:^
{
UIImage * image = [UIImage imageWithData:[NSData dataWithContentsOfURL:
[NSURL URLWithString:[object valueForKey:@"url"]]]];
[object setValue:image forKey:@"image"];
[object setValue:@"completed" forKey:@"status"];
//count set
[[NSOperationQueue mainQueue] addOperationWithBlock:^
{
[_tableViewUsername reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
}];
}];
}
return cell;
}