Skip to content

Commit

Permalink
Retain a reference to the item in SCItemCell
Browse files Browse the repository at this point in the history
This ensures that the icon is cached for the right item even when
scrolling very fast. This is required because the item reference might
have already changed when the icon finishes loading.
  • Loading branch information
koraktor committed Jun 15, 2014
1 parent c0ae89d commit f6bb41a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Suitcase/Classes/SCItemCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,13 @@ - (void)loadImage
}

__weak SCItemCell *weakSelf = self;
id <SCItem> item = self.item;
[self.imageView setImageWithURLRequest:[NSURLRequest requestWithURL:_item.iconUrl]
placeholderImage:kPlaceHolderImage
success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
weakSelf.imageView.image = image;

[SCImageCache cacheIcon:image forItem:weakSelf.item];
[SCImageCache cacheIcon:image forItem:item];
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
#ifdef DEBUG
Expand Down

0 comments on commit f6bb41a

Please sign in to comment.