Skip to content

Commit

Permalink
Fix associated object bug in UIKit extensions (AFNetworking#3872)
Browse files Browse the repository at this point in the history
  • Loading branch information
WELCommand authored and jshier committed Jan 5, 2020
1 parent 2da270b commit 555385d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions UIKit+AFNetworking/UIButton+AFNetworking.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ @implementation UIButton (AFNetworking)

+ (AFImageDownloader *)sharedImageDownloader {

return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
return objc_getAssociatedObject([UIButton class], @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
}

+ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader {
objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
objc_setAssociatedObject([UIButton class], @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

#pragma mark -
Expand Down
4 changes: 2 additions & 2 deletions UIKit+AFNetworking/UIImageView+AFNetworking.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ - (void)af_setActiveImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownload
@implementation UIImageView (AFNetworking)

+ (AFImageDownloader *)sharedImageDownloader {
return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
return objc_getAssociatedObject([UIImageView class], @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
}

+ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader {
objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
objc_setAssociatedObject([UIImageView class], @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

#pragma mark -
Expand Down

0 comments on commit 555385d

Please sign in to comment.