Merge pull request #2178 from dreampiggy/fix_setAnimationImagesWithURLs_dealloc
Fix the issue that `setAnimationImagesWithURLs` weak reference may dealloc before the animated images was set
This commit is contained in:
commit
6717be1346
|
@ -71,15 +71,14 @@
|
|||
|
||||
- (void)sd_setAnimationImagesWithURLs:(nonnull NSArray<NSURL *> *)arrayOfURLs {
|
||||
[self sd_cancelCurrentAnimationImagesLoad];
|
||||
__weak __typeof(self)wself = self;
|
||||
|
||||
NSPointerArray *operationsArray = [self sd_animationOperationArray];
|
||||
|
||||
|
||||
[arrayOfURLs enumerateObjectsUsingBlock:^(NSURL *logoImageURL, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
__weak __typeof(self) wself = self;
|
||||
id <SDWebImageOperation> operation = [[SDWebImageManager sharedManager] loadImageWithURL:logoImageURL options:0 progress:nil completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (!wself) return;
|
||||
__strong typeof(wself) sself = wself;
|
||||
if (!sself) return;
|
||||
dispatch_main_async_safe(^{
|
||||
__strong UIImageView *sself = wself;
|
||||
[sself stopAnimating];
|
||||
if (sself && image) {
|
||||
NSMutableArray<UIImage *> *currentImages = [[sself animationImages] mutableCopy];
|
||||
|
|
Loading…
Reference in New Issue