asihttp 原始碼分析 之四 獲取請求進度
進度條相關的操作都定義在
ASIProgressDelegate .h 檔案中。
而且所有的方法都是optional的。
ipone上更新進度條的方法 :- (void)setProgress:(float)newProgress;
#if TARGET_OS_IPHONE
- (void)setProgress:(float)newProgress;
#else
- (void)setDoubleValue:(double)newProgress;
- (void)setMaxValue:(double)newMax;
#endif
並且這個方法 直接是 @interface UIProgressView : UIView <NSCoding> 類中實現的。所有可以直接把UIProgressView 的例項賦值給ASIHTTPRequest下面的兩個屬性,而無需實現 ASIProgressDelegate 協議。
// Delegate for displaying upload progress (usually an NSProgressIndicator, but you can supply a different object and handle this yourself)
id <ASIProgressDelegate> uploadProgressDelegate;
// Delegate for displaying download progress (usually an NSProgressIndicator, but you can supply a different object and handle this yourself)
id <ASIProgressDelegate> downloadProgressDelegate;
更新進度條的方法
// Updates upload progress (notifies the queue and/or uploadProgressDelegate of this request)
- (void)updateUploadProgress;
// Updates download progress (notifies the queue and/or uploadProgressDelegate of this request)
- (void)updateDownloadProgress;