Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS Table View stuck in loop while trying to cache images
    text
    copied!<p>I am using async to get my images from an xml. Parser is working correctly and I can output the URLs. In the async I am trying to cache the images to a mutable dictionary. I am stuck in a loop and the images will not output at all any more. Here is my code that I am stuck on.</p> <pre><code> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"Got Here"); static NSString *CellIdentifier = @"NewsCell"; NewsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; NSLog(@"Got Here 2"); // Configure the cell... NewsItem *item = [newsItemsArray objectAtIndex:indexPath.row]; cell.newsTitle.text = item.title; NSLog(@"Got Here 3"); NSMutableDictionary *record = [_records objectAtIndex:[indexPath row]]; if ([record valueForKey:@"actualImage"]) { NSLog(@"Record Found"); [cell.newsImage setImage:[record valueForKey:@"actualImage"]]; } else { NSLog(@"Record Not Found"); dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,(unsigned long)NULL), ^(void) { NSLog(item.image); NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:item.image]]; dispatch_async(dispatch_get_main_queue(), ^(void){ [record setValue:[UIImage imageWithData:imageData] forKey:@"actualImage"]; [cell.newsImage setImage:[record valueForKey:@"actualImage"]]; if (tableView) { [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone]; } }); }); } return cell; } </code></pre> <p>Thanks in advance for you help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload