From fa7d19c099764a27f58fef80ec7c36e90e529a69 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Thu, 5 Apr 2018 16:22:58 +0800 Subject: [PATCH] Update the comments and expose the token's request, which can be used for advanced usage. --- SDWebImage/SDWebImageDownloader.h | 14 ++++++++++---- SDWebImage/SDWebImageDownloader.m | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/SDWebImage/SDWebImageDownloader.h b/SDWebImage/SDWebImageDownloader.h index 5e69435b..17b725b7 100644 --- a/SDWebImage/SDWebImageDownloader.h +++ b/SDWebImage/SDWebImageDownloader.h @@ -97,10 +97,16 @@ typedef NSURLRequest * _Nullable (^SDWebImageDownloaderRequestModifierBlock)(NSU The download's URL. */ @property (nonatomic, strong, nullable, readonly) NSURL *url; + /** - The doenload's response. + The download's request. */ -@property (nonatomic, strong, nullable, readonly) NSURLResponse *response; +@property (nonatomic, copy, nullable, readonly) NSURLRequest *request; + +/** + The download's response. + */ +@property (nonatomic, copy, nullable, readonly) NSURLResponse *response; @end @@ -188,7 +194,7 @@ typedef NSURLRequest * _Nullable (^SDWebImageDownloaderRequestModifierBlock)(NSU * before to be called a last time with the full image and finished argument * set to YES. In case of error, the finished argument is always YES. * - * @return A token (SDWebImageDownloadToken) that can be passed to -cancel: to cancel this operation + * @return A token (SDWebImageDownloadToken) that can be used to cancel this operation */ - (nullable SDWebImageDownloadToken *)downloadImageWithURL:(nullable NSURL *)url options:(SDWebImageDownloaderOptions)options @@ -209,7 +215,7 @@ typedef NSURLRequest * _Nullable (^SDWebImageDownloaderRequestModifierBlock)(NSU * @note the progress block is executed on a background queue * @param completedBlock A block called once the download is completed. * - * @return A token (SDWebImageDownloadToken) that can be passed to -cancel: to cancel this operation + * @return A token (SDWebImageDownloadToken) that can be used to cancel this operation */ - (nullable SDWebImageDownloadToken *)downloadImageWithURL:(nullable NSURL *)url options:(SDWebImageDownloaderOptions)options diff --git a/SDWebImage/SDWebImageDownloader.m b/SDWebImage/SDWebImageDownloader.m index 1bc1bf53..20583ade 100644 --- a/SDWebImage/SDWebImageDownloader.m +++ b/SDWebImage/SDWebImageDownloader.m @@ -18,7 +18,8 @@ static void * SDWebImageDownloaderContext = &SDWebImageDownloaderContext; @interface SDWebImageDownloadToken () @property (nonatomic, strong, nullable, readwrite) NSURL *url; -@property (nonatomic, strong, nullable, readwrite) NSURLResponse *response; +@property (nonatomic, copy, nullable, readwrite) NSURLRequest *request; +@property (nonatomic, copy, nullable, readwrite) NSURLResponse *response; @property (nonatomic, strong, nullable, readwrite) id downloadOperationCancelToken; @property (nonatomic, weak, nullable) NSOperation *downloadOperation; @property (nonatomic, weak, nullable) SDWebImageDownloader *downloader; @@ -284,6 +285,7 @@ static void * SDWebImageDownloaderContext = &SDWebImageDownloaderContext; SDWebImageDownloadToken *token = [SDWebImageDownloadToken new]; token.downloadOperation = operation; token.url = url; + token.request = operation.request; token.downloadOperationCancelToken = downloadOperationCancelToken; token.downloader = self;