Skip to content
Permalink
Browse files

Fix associated object bug in UIKit extensions (#3872)

  • Loading branch information
welcommand authored and jshier committed Jan 5, 2020
1 parent 2da270b commit 555385d2b8c6eb736fc2f5e3aeac46ec2d5ffddd
Showing with 4 additions and 4 deletions.
  1. +2 −2 UIKit+AFNetworking/UIButton+AFNetworking.m
  2. +2 −2 UIKit+AFNetworking/UIImageView+AFNetworking.m
@@ -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 -
@@ -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 -

0 comments on commit 555385d

Please sign in to comment.
You can’t perform that action at this time.