繼承于: NSObject
聲明處: SDWebImageDownloader.h
概述
為下載圖片提供專用和優(yōu)化的異步下載器蛔糯。
任務(wù)
-
shouldDecompressImages
屬性 -
maxConcurrentDownload
屬性 -
currentDownloadCount
屬性 -
downloadTimeout
屬性 -
sessionConfiguration
屬性 -
executionOrder
屬性 + sharedDownloader
-
urlCredential
屬性 -
username
屬性 -
password
屬性 -
headerFilter
屬性 - initWithSessionConfiguration:
- setValue:forHTTPHeaderField:
- valueForHTTPHeaderField:
setOperationClass:
– downloadImageWithURL:options:progress:completed:
- cancel:
setSuspended:
cancelAllDownloads
createNewSessionWithConfiguration:
屬性
currentDownloadCount
@property (readonly, nonatomic) NSUInteger currentDownloadCount
討論
顯示當(dāng)前仍然需要下載的大小哩掺。
聲明處
SDWebImageDownloader.h
downloadTimeout
@property (assign, nonatomic) NSTimeInterval downloadTimeout
討論
下載操作的超時(shí)時(shí)間(單位為秒)篮灼。默認(rèn)值為:15.0.
聲明處
SDWebImageDownloader.h
executionOrder
@property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder
討論
修改下載操作的執(zhí)行順序取胎。默認(rèn)值為SDWebImageDownloaderFIFOExecutionOrder魄幕。
聲明處
SDWebImageDownloader.h
headersFilter
@property (nonatomic, copy, nullable) SDWebImageDownloaderHeadersFilterBlock headersFilter
討論
設(shè)置過濾器用來挑選下載圖片的HTTP請(qǐng)求的頭陕贮。
這個(gè)塊在每個(gè)圖片下載請(qǐng)求時(shí)被調(diào)用匣屡,返回在相應(yīng)的HTTP請(qǐng)求中用于HTTP頭的NSDictionary城看。
聲明處
SDWebImageDownloader.h
maxConcurrentDownloads
@property (assign, nonatomic) NSInteger maxConcurrentDownloads
討論
最大的并發(fā)下載數(shù)女气。
聲明處
SDWebImageDownloader.h
password
@property (strong, nonatomic, nullable) NSString *password
討論
設(shè)置密碼。
聲明處
SDWebImageDownloader.h
sessionConfiguration
@property (readonly, nonatomic, nonnull) NSURLSessionConfiguration *sessionConfiguration
討論
NSURLSession內(nèi)部使用的配置测柠。直接修改這個(gè)對(duì)象沒有效果炼鞠。
同見
- createNewSessionWithConfiguration:
聲明處
SDWebImageDownloader.h
shouldDecompressImages
@property (assign, nonatomic) BOOL shouldDecompressImages
討論
解壓已經(jīng)下載和緩存的圖片可以提高性能,但是會(huì)消耗很多的內(nèi)容轰胁。默認(rèn)為YES谒主。設(shè)置為NO,如果你遇到由于大量的消耗內(nèi)存導(dǎo)致崩潰赃阀。
聲明處
SDWebImageDownloader.h
urlCredential
@property (strong, nonatomic, nullable) NSURLCredential *urlCredential
討論
為請(qǐng)求操作設(shè)置默認(rèn)的URL證書霎肯。
聲明處
SDWebImageDownloader.h
username
@property (strong, nonatomic, nullable) NSString *username
討論
設(shè)置用戶名。
聲明處
SDWebImageDownloader.h
類方法
sharedDownloader
+ (nonnull instancetype)sharedDownloader
討論
單例方法榛斯,返回一個(gè)共享的實(shí)例姿现。
返回值
下載類的全局共享實(shí)例。
聲明處
SDWebImageDownloader.h
實(shí)例方法
cancel
- (void)cancel:(nullable SDWebImageDownloadToken *)token
討論
取消一個(gè)使用downloadImageWithURL:options:progress:completed:
生成的在之前隊(duì)列中的下載任務(wù)肖抱。
參數(shù)
token
從downloadImageWithRUL:options:progress:completed:
獲取的token备典,應(yīng)該被取消。
聲明處
SDWebImageDownloader.h
cancelAllDownloads
- (void)cancelAllDownloads
討論
取消隊(duì)列中所有下載操作意述。
聲明處
SDWebImageDownloader.h
createNewSessionWithConfiguration:
- (void)createNewSessionWithConfiguration:(nonnull NSURLSessionConfiguration *)sessionConfiguration
討論
強(qiáng)制SDWebImageDownloader創(chuàng)建和使用一個(gè)根據(jù)提供的配置初始化的新NSURLSession提佣。注意:所有在隊(duì)列中已經(jīng)存在的下載操作都會(huì)被取消。注意:timeoutIntervalForRequest
將會(huì)被重寫荤崇。
參數(shù)
sessionConfiguration
為新NSURLSession使用的配置拌屏。
聲明處
SDWebImageDownloader.h
downloadImageWithURL:options:progress:completed:
- (nullable SDWebImageDownloadToken *)downloadImageWithURL:(nullable NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock completed:(nullable SDWebImageDownloaderCompletedBlock)completedBlock
討論
根據(jù)提供的URL創(chuàng)建一個(gè)SDWebImageDownloader異步下載實(shí)例。
代理在圖片下載完成或發(fā)生一個(gè)錯(cuò)誤后被執(zhí)行术荤。
注意:進(jìn)度塊在后臺(tái)隊(duì)列中執(zhí)行倚喂。
參數(shù)
url
下載圖片的URL。
options
下載需要使用的選項(xiàng)。
progressBlock
在圖片下載過程中端圈,塊被重復(fù)調(diào)用焦读。
completedBlock
一旦下載完成就調(diào)用塊。如果下載成功舱权,image參數(shù)已經(jīng)設(shè)置矗晃,如果發(fā)生錯(cuò)誤,error參數(shù)設(shè)置為這個(gè)錯(cuò)誤信息宴倍。如果SDWebImageDownloaderProgressDownload沒有使用张症,最后的參數(shù)總是YES。SDWebImageDownloaderProgressiveDownload選項(xiàng)鸵贬,在最后一次之前部分圖片對(duì)象重復(fù)調(diào)用塊俗他,finished參數(shù)設(shè)置為NO。完整圖片對(duì)象最后一次調(diào)用塊阔逼,并設(shè)置finished參數(shù)為YES兆衅。假如發(fā)生錯(cuò)誤,finished參數(shù)總是YES颜价。
返回值
一個(gè)token(SDWebImageDownloadToken)涯保。這個(gè)token可以傳送cancel:
來取消下載操作诉濒。
聲明處
SDWebImageDownloader.h
initiWithSessionConfiguration:
- (nonnull instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)sessionConfiguration
討論
根據(jù)指定的會(huì)話配置創(chuàng)建一個(gè)下載器實(shí)例周伦。注意:timeoutIntervalForRequest
將會(huì)被重寫。
返回值
下載器類的實(shí)例未荒。
聲明處
SDWebImageDownloader.h
setOperationClass:
- (void)setOperationClass:(nullable Class)operationClass
討論
設(shè)置SDWebImageDownloaderOperation的子類作為默認(rèn)NSOperation专挪,每次SDWebImage構(gòu)建一個(gè)請(qǐng)求操作去下載一張圖片時(shí)被使用。
參數(shù)
operationClass
SDWebImageDownloaderOperation的子類設(shè)置為默認(rèn)值片排。傳送nil將恢復(fù)為SDWebImageDownloadOperation寨腔。
聲明處
SDWebImageDownloader.h
setSuspended:
- (void)setSuspended:(BOOL)suspended
討論
設(shè)置下載隊(duì)列的暫停狀態(tài)。
聲明處
SDWebImageDownloader.h
setValue:forHTTPHeaderField:
- (void)setValue:(nullable NSString *)value forHTTPHeaderField:(nullable NSString *)field
討論
設(shè)置一個(gè)HTTP頭的值率寡,追加在每一個(gè)下載HTTP請(qǐng)求中迫卢。
參數(shù)
value
頭域的值。使用nil去移除一個(gè)頭冶共。
field
設(shè)置的頭域的名稱乾蛤。
聲明處
SDWebImageDownloader.h
valueForHTTPHeaderField:
- (nullable NSString *)valueForHTTPHeaderField:(nullable NSString *)field
討論
返回指定HTTP頭域的值。
返回值
與頭域相關(guān)聯(lián)的值捅僵。如果沒有一致的頭域則為nil家卖。
聲明處
SDWebImageDownloader.h
// END 今天看了WePhone的創(chuàng)始人自殺的事件,天啊庙楚。程序員總結(jié)起來就是“簡(jiǎn)單卻又膽小的程序員”上荡。這個(gè)是外人的終結(jié)。我卻無力反駁馒闷。