Kevin Harwood 10 жил өмнө
parent
commit
3697462102

+ 8 - 1
AFNetworking/AFURLSessionManager.h

@@ -118,7 +118,7 @@ NS_ASSUME_NONNULL_BEGIN
 ///-------------------------------
 
 /**
- The security policy used by created request operations to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified.
+ The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified.
  */
 @property (nonatomic, strong) AFSecurityPolicy *securityPolicy;
 
@@ -304,6 +304,13 @@ NS_ASSUME_NONNULL_BEGIN
 /// @name Getting Progress for Tasks
 ///---------------------------------
 
+/**
+ Returns the response download progress of the specified task.
+
+ @param dataTask The session data task. Must not be `nil`.
+
+ @return An `NSProgress` object reporting the response download progress of a task, or `nil` if the progress is unavailable.
+ */
 - (nullable NSProgress *)progressForDataTask:(NSURLSessionDataTask *)dataTask;
 
 /**

+ 4 - 0
Example/AFNetworking Example.xcodeproj/project.pbxproj

@@ -52,6 +52,8 @@
 		291BFE351BB9ED7F00FFB029 /* Gravatar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 291BFE341BB9ED7F00FFB029 /* Gravatar.swift */; };
 		291BFE371BB9EDD700FFB029 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 291BFE361BB9EDD700FFB029 /* UIKit.framework */; };
 		291BFE3A1BBAD2FF00FFB029 /* UIWebView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 291BFE391BBAD2FF00FFB029 /* UIWebView+AFNetworking.m */; };
+		291BFE611BBB396800FFB029 /* AFAutoPurgingImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 29E6F1BE1BB9DE1100A4466C /* AFAutoPurgingImageCache.m */; };
+		291BFE621BBB396B00FFB029 /* AFImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 29E6F1C01BB9DE1100A4466C /* AFImageDownloader.m */; };
 		29E6F17A1BB9DCB500A4466C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29E6F1791BB9DCB500A4466C /* main.m */; };
 		29E6F1A41BB9DD7300A4466C /* Post.m in Sources */ = {isa = PBXBuildFile; fileRef = 29E6F19A1BB9DD7300A4466C /* Post.m */; };
 		29E6F1A51BB9DD7300A4466C /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = 29E6F19C1BB9DD7300A4466C /* User.m */; };
@@ -742,7 +744,9 @@
 				291BFDDF1BB9E86000FFB029 /* AFURLRequestSerialization.m in Sources */,
 				291BFDE11BB9E86000FFB029 /* AFURLSessionManager.m in Sources */,
 				291BFDE01BB9E86000FFB029 /* AFURLResponseSerialization.m in Sources */,
+				291BFE611BBB396800FFB029 /* AFAutoPurgingImageCache.m in Sources */,
 				291BFDE21BB9E86400FFB029 /* AFNetworkReachabilityManager.m in Sources */,
+				291BFE621BBB396B00FFB029 /* AFImageDownloader.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

+ 91 - 0
UIKit+AFNetworking/AFAutoPurgingImageCache.h

@@ -27,27 +27,118 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
+/**
+ The `AFImageCache` protocol defines a set of APIs for adding, removing and fetching images from a cache synchronously.
+ */
 @protocol AFImageCache <NSObject>
 
+/**
+ Adds the image to the cache with the given identifier.
+
+ @param image The image to cache.
+ @param identifier The unique identifier for the image in the cache.
+ */
 - (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier;
+
+/**
+ Removes the image from the cache matching the given identifier.
+
+ @param identifier The unique identifier for the image in the cache.
+
+ @return A BOOL indicating whether or not the image was removed from the cache.
+ */
 - (BOOL)removeImageWithIdentifier:(NSString *)identifier;
+
+/**
+ Removes all images from the cache.
+
+ @return A BOOL indicating whether or not all images were removed from the cache.
+ */
 - (BOOL)removeAllImages;
+
+/**
+ Returns the image in the cache associated with the given identifier.
+
+ @param identifier The unique identifier for the image in the cache.
+
+ @return An image for the matching identifier, or nil.
+ */
 - (nullable UIImage *)imageWithIdentifier:(NSString *)identifier;
 @end
 
+
+/**
+ The `ImageRequestCache` protocol extends the `ImageCache` protocol by adding methods for adding, removing and fetching images from a cache given an `NSURLRequest` and additional identifier.
+ */
 @protocol AFImageRequestCache <NSObject>
 
+/**
+ Adds the image to the cache using an identifier created from the request and additional identifier.
+
+ @param image The image to cache.
+ @param request The unique URL request identifing the image asset.
+ @param identifier The additional identifier to apply to the URL request to identify the image.
+ */
 - (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
+
+/**
+ Removes the image from the cache using an identifier created from the request and additional identifier.
+
+ @param request The unique URL request identifing the image asset.
+ @param identifier The additional identifier to apply to the URL request to identify the image.
+ 
+ @return A BOOL indicating whether or not all images were removed from the cache.
+ */
 - (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
+
+/**
+ Returns the image from the cache associated with an identifier created from the request and additional identifier.
+
+ @param request The unique URL request identifing the image asset.
+ @param identifier The additional identifier to apply to the URL request to identify the image.
+
+ @return An image for the matching request and identifier, or nil.
+ */
 - (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
 
 @end
 
+/**
+ The `AutoPurgingImageCache` in an in-memory image cache used to store images up to a given memory capacity. When the memory capacity is reached, the image cache is sorted by last access date, then the oldest image is continuously purged until the preferred memory usage after purge is met. Each time an image is accessed through the cache, the internal access date of the image is updated.
+ */
 @interface AFAutoPurgingImageCache : NSObject <AFImageRequestCache>
 
+/**
+ The total memory capacity of the cache in bytes.
+ */
 @property (nonatomic, assign) UInt64 memoryCapacity;
+
+/**
+ The preferred memory usage after purge in bytes. During a purge, images will be purged until the memory capacity drops below this limit.
+ */
 @property (nonatomic, assign) UInt64 preferredMemoryUsageAfterPurge;
 
+/**
+ The current total memory usage in bytes of all images stored within the cache.
+ */
+@property (nonatomic, assign, readonly) UInt64 currentMemoryUsage;
+
+/**
+ Initialies the `AutoPurgingImageCache` instance with default values for memory capacity and preferred memory usage after purge limit. `memoryCapcity` defaults to `100 MB`. `preferredMemoryUsageAfterPurge` defaults to `60 MB`.
+
+ @return The new `AutoPurgingImageCache` instance.
+ */
+- (instancetype)init;
+
+/**
+ Initialies the `AutoPurgingImageCache` instance with the given memory capacity and preferred memory usage
+ after purge limit.
+
+ @param memoryCapacity The total memory capacity of the cache in bytes.
+ @param preferredMemoryUsageAfterPurge The preferred memory usage after purge in bytes.
+
+ @return The new `AutoPurgingImageCache` instance.
+ */
 - (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity;
 
 @end

+ 2 - 1
UIKit+AFNetworking/AFAutoPurgingImageCache.m

@@ -18,9 +18,10 @@
 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
+
 #import <TargetConditionals.h>
 
-#if TARGET_OS_IOS || TARGET_OS_TV
+#if TARGET_OS_IOS || TARGET_OS_TV 
 
 #import "AFAutoPurgingImageCache.h"
 

+ 68 - 3
UIKit+AFNetworking/AFImageDownloader.h

@@ -21,7 +21,7 @@
 
 #import <TargetConditionals.h>
 
-#if TARGET_OS_IOS || TARGET_OS_TV
+#if TARGET_OS_IOS || TARGET_OS_TV 
 
 #import <Foundation/Foundation.h>
 #import "AFAutoPurgingImageCache.h"
@@ -34,28 +34,93 @@ typedef NS_ENUM(NSInteger, AFImageDownloadPrioritization) {
     AFImageDownloadPrioritizationLIFO
 };
 
+/**
+ The `AFImageDownloadReceipt` is an object vended by the `AFImageDownloader` when starting a data task. It can be used to cancel active tasks running on the `AFImageDownloader` session. As a general rule, image data tasks should be cancelled using the `AFImageDownloadReceipt` instead of calling `cancel` directly on the `task` itself. The `AFImageDownloader` is optimized to handle duplicate task scenarios as well as pending versus active downloads.
+ */
 @interface AFImageDownloadReceipt : NSObject
+
+/**
+ The data task created by the `AFImageDownloader`.
+*/
 @property (nonatomic, strong) NSURLSessionDataTask *task;
+
+/**
+ The unique identifier for the success and failure blocks when duplicate requests are made.
+ */
 @property (nonatomic, strong) NSUUID *receiptID;
 @end
 
+/** The `AFImageDownloader` class is responsible for downloading images in parallel on a prioritized queue. Incoming downloads are added to the front or back of the queue depending on the download prioritization. Each downloaded image is cached in the underlying `NSURLCache` as well as the in-memory image cache. By default, any download request with a cached image equivalent in the image cache will automatically be served the cached image representation.
+ */
 @interface AFImageDownloader : NSObject
 
+/**
+ The image cache used to store all downloaded images in. `AFAutoPurgingImageCache` by default.
+ */
 @property (nonatomic, strong, nullable) id <AFImageRequestCache> imageCache;
+
+/**
+ The `AFHTTPSessionManager` used to download images. By default, this is configured with an `AFImageResponseSerializer`, and a shared `NSURLCache` for all image downloads.
+ */
 @property (nonatomic, strong) AFHTTPSessionManager *sessionManager;
+
+/**
+ Defines the order prioritization of incoming download requests being inserted into the queue. `AFImageDownloadPrioritizationFIFO` by default.
+ */
 @property (nonatomic, assign) AFImageDownloadPrioritization downloadPrioritizaton;
 
+/**
+ The shared default instance of `AFImageDownloader` initialized with default values.
+ */
 + (instancetype)defaultInstance;
 
+/**
+ Default initializer
+
+ @return An instance of `AFImageDownloader` initialized with default values.
+ */
+- (instancetype)init;
+
+/**
+ Initializes the `AFImageDownloader` instance with the given session manager, download prioritization, maximum active download count and image cache.
+
+ @param sessionManager The session manager to use to download images
+ @param downloadPrioritization The download prioritization of the download queue.
+ @param maximumActiveDownloads  The maximum number of active downloads allowed at any given time. Recommend `4`.
+ @param imageCache The image cache used to store all downloaded images in.
+
+ @return The new `AFImageDownloader` instance.
+ */
 - (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager
                 downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization
                 maximumActiveDownloads:(NSInteger)maximumActiveDownloads
                             imageCache:(nullable id <AFImageRequestCache>)imageCache;
 
+/**
+ Creates a data task using the `sessionManager` instance for the specified URL request.
+
+ If the same data task is already in the queue or currently being downloaded, the success and failure blocks are
+ appended to the already existing task. Once the task completes, all success or failure blocks attached to the
+ task are executed in the order they were added.
+
+ @param request The URL request.
+ @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
+ @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
+
+ @return The image download receipt for the data task if available. `nil` if the image is stored in the image
+ cache and the URL request cache policy allows the cache to be used.
+ */
 - (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
-                                               success:(nullable void (^)(NSURLSessionDataTask *task, UIImage *responseObject))success
-                                               failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure;
+                                                        success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse  * _Nullable response, UIImage *responseObject))success
+                                                        failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
+
+/**
+ Cancels the data task in the receipt by removing the corresponding success and failure blocks and cancelling the data task if necessary.
+
+ If the data task is pending in the queue, it will be cancelled if no other success and failure blocks are registered with the data task. If the data task is currently executing or is already completed, the success and failure blocks are removed and will not be called when the task finishes.
 
+ @param imageDownloadReceipt The image download receipt to cancel.
+ */
 - (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt;
 
 @end

+ 11 - 11
UIKit+AFNetworking/AFImageDownloader.m

@@ -21,22 +21,22 @@
 
 #import <TargetConditionals.h>
 
-#if TARGET_OS_IOS || TARGET_OS_TV
+#if TARGET_OS_IOS || TARGET_OS_TV 
 
 #import "AFImageDownloader.h"
 #import "AFHTTPSessionManager.h"
 
 @interface AFImageDownloaderResponseHandler : NSObject
 @property (nonatomic, strong) NSUUID *uuid;
-@property (nonatomic, copy) void (^successBlock)(NSURLSessionDataTask*, UIImage*);
-@property (nonatomic, copy) void (^failureBlock)(NSURLSessionDataTask*, NSError*);
+@property (nonatomic, copy) void (^successBlock)(NSURLRequest*, NSHTTPURLResponse*, UIImage*);
+@property (nonatomic, copy) void (^failureBlock)(NSURLRequest*, NSHTTPURLResponse*, NSError*);
 @end
 
 @implementation AFImageDownloaderResponseHandler
 
 - (instancetype)initWithUUID:(NSUUID *)uuid
-                    success:(nullable void (^)(NSURLSessionDataTask *task, UIImage *responseObject))success
-                    failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure {
+                    success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
+                    failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure {
     if (self = [self init]) {
         self.uuid = uuid;
         self.successBlock = success;
@@ -172,8 +172,8 @@
 }
 
 - (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
-                           success:(nullable void (^)(NSURLSessionDataTask *task, UIImage *responseObject))success
-                           failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure {
+                                                        success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse  * _Nullable response, UIImage *responseObject))success
+                                                        failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; {
 
     __block AFImageDownloadReceipt *downloadReceipt = nil;
     dispatch_sync(self.synchronizationQueue, ^{
@@ -196,7 +196,7 @@
                 if (cachedImage != nil) {
                     dispatch_async(dispatch_get_main_queue(), ^{
                         if (success) {
-                            success(nil, cachedImage);
+                            success(request, nil, cachedImage);
                         }
                     });
                     return;
@@ -218,7 +218,7 @@
                            AFImageDownloaderMergedTask *mergedTask = [strongSelf safelyRemoveMergedTaskWithIdentifier:identifier];
                            for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) {
                                dispatch_async(dispatch_get_main_queue(), ^{
-                                   handler.successBlock(task, responseObject);
+                                   handler.successBlock(task.originalRequest, (NSHTTPURLResponse*)task.response, responseObject);
                                });
                            }
                            [strongSelf safelyDecrementActiveTaskCount];
@@ -229,7 +229,7 @@
                            AFImageDownloaderMergedTask *mergedTask = [strongSelf safelyRemoveMergedTaskWithIdentifier:identifier];
                            for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) {
                                dispatch_async(dispatch_get_main_queue(), ^{
-                                   handler.failureBlock(task, error);
+                                   handler.failureBlock(task.originalRequest, (NSHTTPURLResponse*)task.response, error);
                                });
                            }
                            [strongSelf safelyDecrementActiveTaskCount];
@@ -277,7 +277,7 @@
             NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo];
             if (handler.failureBlock) {
                 dispatch_async(dispatch_get_main_queue(), ^{
-                    handler.failureBlock(imageDownloadReceipt.task, error);
+                    handler.failureBlock(imageDownloadReceipt.task.originalRequest, nil, error);
                 });
             }
         }

+ 1 - 1
UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h

@@ -30,7 +30,7 @@
 NS_ASSUME_NONNULL_BEGIN
 
 /**
- `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a network request operation has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero.
+ `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a session task has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero.
 
  You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code:
 

+ 1 - 1
UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h

@@ -28,7 +28,7 @@
 #import <UIKit/UIKit.h>
 
 /**
- This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a request operation or session task.
+ This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task.
  */
 @interface UIActivityIndicatorView (AFNetworking)
 

+ 1 - 1
UIKit+AFNetworking/UIAlertView+AFNetworking.h

@@ -31,7 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 /**
- This category adds methods to the UIKit framework's `UIAlertView` class. The methods in this category provide support for automatically showing an alert if a session task or request operation finishes with an error. Alert title and message are filled from the corresponding `localizedDescription` & `localizedRecoverySuggestion` or `localizedFailureReason` of the error.
+ This category adds methods to the UIKit framework's `UIAlertView` class. The methods in this category provide support for automatically showing an alert if a session task finishes with an error. Alert title and message are filled from the corresponding `localizedDescription` & `localizedRecoverySuggestion` or `localizedFailureReason` of the error.
  */
 @interface UIAlertView (AFNetworking)
 

+ 24 - 29
UIKit+AFNetworking/UIButton+AFNetworking.h.orig

@@ -38,30 +38,30 @@ NS_ASSUME_NONNULL_BEGIN
  */
 @interface UIButton (AFNetworking)
 
-<<<<<<< 1bfb8495a47f037560cc2c13302b70c4d58bb50b
-///----------------------------
-/// @name Accessing Image Cache
-///----------------------------
-
-/**
- The image cache used to improve image loading performance on scroll views. By default, `UIButton` will use the `sharedImageCache` of `UIImageView`.
- */
-+ (id <AFImageCache>)sharedImageCache;
+///------------------------------------
+/// @name Accessing the Image Downloader
+///------------------------------------
 
 /**
- Set the cache used for image loading.
-
- @param imageCache The image cache.
+ Set the shared image downloader used to download images.
+<<<<<<< b4f8a67ba4dabf3e3365512f70fc0a83644ed21c
+ @param imageDownloader The shared image downloader used to download images.
  */
-+ (void)setSharedImageCache:(__nullable id <AFImageCache>)imageCache;
 =======
+
+ @param imageDownloader The shared image downloader used to download images.
+*/
+>>>>>>> Added documentation
 + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader;
->>>>>>> - Removed support for NSURLConnection based API's
 
-///------------------------------------
-/// @name Accessing Response Serializer
-///------------------------------------
+/**
+ The shared image downloader used to download images.
+ */
++ (AFImageDownloader *)sharedImageDownloader;
+<<<<<<< b4f8a67ba4dabf3e3365512f70fc0a83644ed21c
 
+=======
+>>>>>>> Added documentation
 
 ///--------------------
 /// @name Setting Image
@@ -101,19 +101,19 @@ NS_ASSUME_NONNULL_BEGIN
  @param state The control state.
  @param urlRequest The URL request used for the image request.
  @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes.
+<<<<<<< b4f8a67ba4dabf3e3365512f70fc0a83644ed21c
  @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes two arguments: the server response and the image. If the image was returned from cache, the response parameter will be `nil`.
  @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes a single argument: the error that occurred.
+=======
+ @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes two arguments: the server response and the image. If the image was returned from cache, the request and response parameters will be `nil`.
+ @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
+>>>>>>> Added documentation
  */
 - (void)setImageForState:(UIControlState)state
           withURLRequest:(NSURLRequest *)urlRequest
         placeholderImage:(nullable UIImage *)placeholderImage
-<<<<<<< 1bfb8495a47f037560cc2c13302b70c4d58bb50b
-                 success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success
-                 failure:(nullable void (^)(NSError *error))failure;
-=======
-                 success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
+                 success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
                  failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
->>>>>>> - Removed support for NSURLConnection based API's
 
 
 ///-------------------------------
@@ -160,13 +160,8 @@ NS_ASSUME_NONNULL_BEGIN
 - (void)setBackgroundImageForState:(UIControlState)state
                     withURLRequest:(NSURLRequest *)urlRequest
                   placeholderImage:(nullable UIImage *)placeholderImage
-<<<<<<< 1bfb8495a47f037560cc2c13302b70c4d58bb50b
-                           success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success
-                           failure:(nullable void (^)(NSError *error))failure;
-=======
-                           success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
+                           success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
                            failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
->>>>>>> - Removed support for NSURLConnection based API's
 
 
 ///------------------------------

+ 12 - 12
UIKit+AFNetworking/UIButton+AFNetworking.m

@@ -164,11 +164,11 @@ static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState
         AFImageDownloadReceipt *receipt;
         receipt = [downloader
                    downloadImageForURLRequest:urlRequest
-                   success:^(NSURLSessionDataTask * _Nonnull task, UIImage * _Nonnull responseObject) {
+                   success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
                        __strong __typeof(weakSelf)strongSelf = weakSelf;
-                       if ([strongSelf isActiveTaskURLEqualToURLRequest:task.originalRequest forState:state]) {
+                       if ([strongSelf isActiveTaskURLEqualToURLRequest:request forState:state]) {
                            if (success) {
-                               success(task.originalRequest, (NSHTTPURLResponse *)task.response, responseObject);
+                               success(request, response, responseObject);
                            } else if(responseObject) {
                                [strongSelf setImage:responseObject forState:state];
                            }
@@ -176,11 +176,11 @@ static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState
                        }
 
                    }
-                   failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
+                   failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
                        __strong __typeof(weakSelf)strongSelf = weakSelf;
-                       if ([strongSelf isActiveTaskURLEqualToURLRequest:task.originalRequest forState:state]) {
+                       if ([strongSelf isActiveTaskURLEqualToURLRequest:request forState:state]) {
                            if (failure) {
-                               failure(task.originalRequest, (NSHTTPURLResponse *)task.response, error);
+                               failure(request, response, error);
                            }
                            [strongSelf  af_setImageDownloadReceipt:nil forState:state];
                        }
@@ -241,11 +241,11 @@ static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState
         AFImageDownloadReceipt *receipt;
         receipt = [downloader
                    downloadImageForURLRequest:urlRequest
-                   success:^(NSURLSessionDataTask * _Nonnull task, UIImage * _Nonnull responseObject) {
+                   success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
                        __strong __typeof(weakSelf)strongSelf = weakSelf;
-                       if ([strongSelf isActiveBackgroundTaskURLEqualToURLRequest:task.originalRequest forState:state]) {
+                       if ([strongSelf isActiveBackgroundTaskURLEqualToURLRequest:request forState:state]) {
                            if (success) {
-                               success(task.originalRequest, (NSHTTPURLResponse *)task.response, responseObject);
+                               success(request, response, responseObject);
                            } else if(responseObject) {
                                [strongSelf setImage:responseObject forState:state];
                            }
@@ -253,11 +253,11 @@ static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState
                        }
 
                    }
-                   failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
+                   failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
                        __strong __typeof(weakSelf)strongSelf = weakSelf;
-                       if ([strongSelf isActiveBackgroundTaskURLEqualToURLRequest:task.originalRequest forState:state]) {
+                       if ([strongSelf isActiveBackgroundTaskURLEqualToURLRequest:request forState:state]) {
                            if (failure) {
-                               failure(task.originalRequest, (NSHTTPURLResponse *)task.response, error);
+                               failure(request, response, error);
                            }
                            [strongSelf  af_setBackgroundImageDownloadReceipt:nil forState:state];
                        }

+ 3 - 3
UIKit+AFNetworking/UIImageView+AFNetworking.h

@@ -42,11 +42,11 @@ NS_ASSUME_NONNULL_BEGIN
 
 /**
  Set the shared image downloader used to download images.
+
  @param imageDownloader The shared image downloader used to download images.
  */
 + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader;
 
-
 /**
  The shared image downloader used to download images.
  */
@@ -89,8 +89,8 @@ NS_ASSUME_NONNULL_BEGIN
 
  @param urlRequest The URL request used for the image request.
  @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
- @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
- @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
+ @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
+ @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
  */
 - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
               placeholderImage:(nullable UIImage *)placeholderImage

+ 15 - 26
UIKit+AFNetworking/UIImageView+AFNetworking.h.orig

@@ -36,34 +36,28 @@ NS_ASSUME_NONNULL_BEGIN
  */
 @interface UIImageView (AFNetworking)
 
-+ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader;
-
-<<<<<<< 1bfb8495a47f037560cc2c13302b70c4d58bb50b
-/**
- The image cache used to improve image loading performance on scroll views. By default, this is an `NSCache` subclass conforming to the `AFImageCache` protocol, which listens for notification warnings and evicts objects accordingly.
-*/
-+ (id <AFImageCache>)sharedImageCache;
+///------------------------------------
+/// @name Accessing the Image Downloader
+///------------------------------------
 
 /**
- Set the cache used for image loading.
+ Set the shared image downloader used to download images.
+<<<<<<< b4f8a67ba4dabf3e3365512f70fc0a83644ed21c
+=======
 
- @param imageCache The image cache.
+>>>>>>> Added documentation
+ @param imageDownloader The shared image downloader used to download images.
  */
-+ (void)setSharedImageCache:(__nullable id <AFImageCache>)imageCache;
++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader;
 
-///------------------------------------
-/// @name Accessing Response Serializer
-///------------------------------------
+<<<<<<< b4f8a67ba4dabf3e3365512f70fc0a83644ed21c
 
+=======
+>>>>>>> Added documentation
 /**
- The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`.
-
- @discussion Subclasses of `AFImageResponseSerializer` could be used to perform post-processing, such as color correction, face detection, or other effects. See https://github.com/AFNetworking/AFCoreImageSerializer
+ The shared image downloader used to download images.
  */
-@property (nonatomic, strong) id <AFURLResponseSerialization> imageResponseSerializer;
-=======
 + (AFImageDownloader *)sharedImageDownloader;
->>>>>>> - Removed support for NSURLConnection based API's
 
 ///--------------------
 /// @name Setting Image
@@ -102,18 +96,13 @@ NS_ASSUME_NONNULL_BEGIN
 
  @param urlRequest The URL request used for the image request.
  @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
- @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
- @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
+ @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
+ @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
  */
 - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
               placeholderImage:(nullable UIImage *)placeholderImage
-<<<<<<< 1bfb8495a47f037560cc2c13302b70c4d58bb50b
-                       success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success
-                       failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, NSError *error))failure;
-=======
                        success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
                        failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
->>>>>>> - Removed support for NSURLConnection based API's
 
 /**
  Cancels any executing image operation for the receiver, if one exists.

+ 6 - 6
UIKit+AFNetworking/UIImageView+AFNetworking.m

@@ -106,11 +106,11 @@
         AFImageDownloadReceipt *receipt;
         receipt = [downloader
                    downloadImageForURLRequest:urlRequest
-                   success:^(NSURLSessionDataTask * _Nonnull task, UIImage * _Nonnull responseObject) {
+                   success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
                        __strong __typeof(weakSelf)strongSelf = weakSelf;
-                       if ([strongSelf isActiveTaskURLEqualToURLRequest:task.originalRequest]) {
+                       if ([strongSelf isActiveTaskURLEqualToURLRequest:request]) {
                            if (success) {
-                               success(task.originalRequest, (NSHTTPURLResponse *)task.response, responseObject);
+                               success(request, response, responseObject);
                            } else if(responseObject) {
                                strongSelf.image = responseObject;
                            }
@@ -118,11 +118,11 @@
                        }
 
                    }
-                   failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
+                   failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
                        __strong __typeof(weakSelf)strongSelf = weakSelf;
-                        if ([strongSelf isActiveTaskURLEqualToURLRequest:task.originalRequest]) {
+                        if ([strongSelf isActiveTaskURLEqualToURLRequest:request]) {
                             if (failure) {
-                                failure(task.originalRequest, (NSHTTPURLResponse *)task.response, error);
+                                failure(request, response, error);
                             }
                             strongSelf.af_activeImageDownloadReceipt = nil;
                         }

+ 1 - 1
UIKit+AFNetworking/UIProgressView+AFNetworking.h

@@ -31,7 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 /**
- This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task or request operation.
+ This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task.
  */
 @interface UIProgressView (AFNetworking)
 

+ 1 - 1
UIKit+AFNetworking/UIRefreshControl+AFNetworking.h

@@ -31,7 +31,7 @@
 NS_ASSUME_NONNULL_BEGIN
 
 /**
- This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a request operation or session task.
+ This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a session task.
  */
 @interface UIRefreshControl (AFNetworking)
 

+ 5 - 2
UIKit+AFNetworking/UIWebView+AFNetworking.h

@@ -38,6 +38,9 @@ NS_ASSUME_NONNULL_BEGIN
  */
 @interface UIWebView (AFNetworking)
 
+/**
+ The session manager used to download all requests.
+ */
 @property (nonatomic, strong) AFHTTPSessionManager *sessionManager;
 
 /**
@@ -46,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
  @param request A URL request identifying the location of the content to load. This must not be `nil`.
  @param progress A progress object monitoring the current download progress.
  @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string.
- @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
+ @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
  */
 - (void)loadRequest:(NSURLRequest *)request
            progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
@@ -61,7 +64,7 @@ NS_ASSUME_NONNULL_BEGIN
  @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified.
 @param progress A progress object monitoring the current download progress.
  @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data.
- @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
+ @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
  */
 - (void)loadRequest:(NSURLRequest *)request
            MIMEType:(nullable NSString *)MIMEType

+ 1 - 1
UIKit+AFNetworking/UIWebView+AFNetworking.m

@@ -146,7 +146,7 @@
                 }
             }];
     self.af_URLSessionTask = task;
-    progress = [self.sessionManager progressForDataTask:task];
+    *progress = [self.sessionManager progressForDataTask:task];
     [self.af_URLSessionTask resume];
 
     if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {