Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First of all replace </p> <pre> [record setValue:[UIImage imageWithData:imageData] forKey:@"actualImage"]; with [record setObject:[UIImage imageWithData:imageData] forKey:@"actualImage"]; </pre> <p>and your code should work. Since the dictionary is always empty it always goes to else block. Print NSMutableDictionary and you will realize this.</p> <p>This is not the way caching is done. It's not only about memory but also about coding practices. </p> <p>Please use a clean approach like NSCache or <a href="https://github.com/rs/SDWebImage" rel="nofollow">SDWebImage</a></p> <p>SDWebImage takes care of caching as well. Use NSOperation to make request rather than GCD. to avoid nested blocks and concerrency issues. Here is how a clean code looks like</p> <pre> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"cell"; NewsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; NewsItem *item = [newsItemsArray objectAtIndex:indexPath.row]; cell.newsTitle.text = item.title; // category from library [cell.imageView setImageWithURL:newsItem.imageURL]; if ([item needsRefresh] ) { cell.newsTitle.text = item.title; NewsOperation *operation = [[NewsOperation alloc] initForNewsItem:newItem completion:^(NewsItem *newsItem, NSError *error) { if (newsItem) { [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; } }]; [[self newsItemQueue] addOperation:operation]; } return cell; } </pre>
 

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