Skip to content

Commit

Permalink
Fixed potential crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
davbeck committed Mar 20, 2015
1 parent 0d09c9e commit a256b08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 4 additions & 2 deletions Pod/Classes/PHImageManager+TNKRequestImages.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ - (NSDictionary *)requestImagesForAssets:(NSArray *)assets
dispatch_group_enter(group);

PHImageRequestID requestID = [self requestImageForAsset:asset targetSize:targetSize contentMode:contentMode options:options resultHandler:^(UIImage *result, NSDictionary *info) {
results[asset.localIdentifier] = result;
infos[asset.localIdentifier] = info;
if (result != nil && info != nil) {
results[asset.localIdentifier] = result;
infos[asset.localIdentifier] = info;
}

dispatch_group_leave(group);
}];
Expand Down
14 changes: 8 additions & 6 deletions Pod/Classes/TNKAssetImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ @implementation TNKAssetImageView

- (void)setAsset:(PHAsset *)asset
{
[self cancelAssetImageRequest];

_asset = asset;
self.image = self.defaultImage;

[self setNeedsAssetReload];
if (_asset != asset) {
[self cancelAssetImageRequest];

_asset = asset;
self.image = self.defaultImage;

[self setNeedsAssetReload];
}
}

- (void)setNeedsAssetReload
Expand Down

0 comments on commit a256b08

Please sign in to comment.