Update the comments and expose the token's request, which can be used for advanced usage.

This commit is contained in:
DreamPiggy 2018-04-05 16:22:58 +08:00
parent f01fe38fdd
commit fa7d19c099
2 changed files with 13 additions and 5 deletions

View File

@ -97,10 +97,16 @@ typedef NSURLRequest * _Nullable (^SDWebImageDownloaderRequestModifierBlock)(NSU
The download's URL. The download's URL.
*/ */
@property (nonatomic, strong, nullable, readonly) NSURL *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 @end
@ -188,7 +194,7 @@ typedef NSURLRequest * _Nullable (^SDWebImageDownloaderRequestModifierBlock)(NSU
* before to be called a last time with the full image and finished argument * 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. * 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 - (nullable SDWebImageDownloadToken *)downloadImageWithURL:(nullable NSURL *)url
options:(SDWebImageDownloaderOptions)options options:(SDWebImageDownloaderOptions)options
@ -209,7 +215,7 @@ typedef NSURLRequest * _Nullable (^SDWebImageDownloaderRequestModifierBlock)(NSU
* @note the progress block is executed on a background queue * @note the progress block is executed on a background queue
* @param completedBlock A block called once the download is completed. * @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 - (nullable SDWebImageDownloadToken *)downloadImageWithURL:(nullable NSURL *)url
options:(SDWebImageDownloaderOptions)options options:(SDWebImageDownloaderOptions)options

View File

@ -18,7 +18,8 @@ static void * SDWebImageDownloaderContext = &SDWebImageDownloaderContext;
@interface SDWebImageDownloadToken () @interface SDWebImageDownloadToken ()
@property (nonatomic, strong, nullable, readwrite) NSURL *url; @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, strong, nullable, readwrite) id downloadOperationCancelToken;
@property (nonatomic, weak, nullable) NSOperation<SDWebImageDownloaderOperation> *downloadOperation; @property (nonatomic, weak, nullable) NSOperation<SDWebImageDownloaderOperation> *downloadOperation;
@property (nonatomic, weak, nullable) SDWebImageDownloader *downloader; @property (nonatomic, weak, nullable) SDWebImageDownloader *downloader;
@ -284,6 +285,7 @@ static void * SDWebImageDownloaderContext = &SDWebImageDownloaderContext;
SDWebImageDownloadToken *token = [SDWebImageDownloadToken new]; SDWebImageDownloadToken *token = [SDWebImageDownloadToken new];
token.downloadOperation = operation; token.downloadOperation = operation;
token.url = url; token.url = url;
token.request = operation.request;
token.downloadOperationCancelToken = downloadOperationCancelToken; token.downloadOperationCancelToken = downloadOperationCancelToken;
token.downloader = self; token.downloader = self;