Put download token init internal

This commit is contained in:
zhongwuzw 2018-08-09 17:21:24 +08:00
parent ab5b5677b2
commit 22a8c43bca
2 changed files with 4 additions and 11 deletions

View File

@ -91,8 +91,6 @@ FOUNDATION_EXPORT NSString * _Nonnull const SDWebImageDownloadStopNotification;
typedef SDImageLoaderProgressBlock SDWebImageDownloaderProgressBlock; typedef SDImageLoaderProgressBlock SDWebImageDownloaderProgressBlock;
typedef SDImageLoaderCompletedBlock SDWebImageDownloaderCompletedBlock; typedef SDImageLoaderCompletedBlock SDWebImageDownloaderCompletedBlock;
@protocol SDWebImageDownloaderOperation;
/** /**
* A token associated with each download. Can be used to cancel a download * A token associated with each download. Can be used to cancel a download
*/ */
@ -118,11 +116,6 @@ typedef SDImageLoaderCompletedBlock SDWebImageDownloaderCompletedBlock;
*/ */
@property (nonatomic, strong, nullable, readonly) NSURLResponse *response; @property (nonatomic, strong, nullable, readonly) NSURLResponse *response;
/**
Init download token with downloadOperation.
*/
- (nonnull instancetype)initWithDownloadOperation:(nullable NSOperation<SDWebImageDownloaderOperation> *)downloadOperation;
@end @end

View File

@ -23,6 +23,10 @@ static void * SDWebImageDownloaderContext = &SDWebImageDownloaderContext;
@property (nonatomic, weak, nullable) SDWebImageDownloader *downloader; @property (nonatomic, weak, nullable) SDWebImageDownloader *downloader;
@property (nonatomic, assign, getter=isCancelled) BOOL cancelled; @property (nonatomic, assign, getter=isCancelled) BOOL cancelled;
- (nonnull instancetype)init NS_UNAVAILABLE;
+ (nonnull instancetype)new NS_UNAVAILABLE;
- (nonnull instancetype)initWithDownloadOperation:(nullable NSOperation<SDWebImageDownloaderOperation> *)downloadOperation NS_DESIGNATED_INITIALIZER;
@end @end
@interface SDWebImageDownloader () <NSURLSessionTaskDelegate, NSURLSessionDataDelegate> @interface SDWebImageDownloader () <NSURLSessionTaskDelegate, NSURLSessionDataDelegate>
@ -431,10 +435,6 @@ didReceiveResponse:(NSURLResponse *)response
[[NSNotificationCenter defaultCenter] removeObserver:self name:SDWebImageDownloadReceiveResponseNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:SDWebImageDownloadReceiveResponseNotification object:nil];
} }
- (instancetype)init {
return [self initWithDownloadOperation:nil];
}
- (instancetype)initWithDownloadOperation:(NSOperation<SDWebImageDownloaderOperation> *)downloadOperation { - (instancetype)initWithDownloadOperation:(NSOperation<SDWebImageDownloaderOperation> *)downloadOperation {
self = [super init]; self = [super init];
if (self) { if (self) {