较新的RestKit
0.2.x很棒,但我找不到RKHTTPRequestOperation : AFHTTPRequestOperation : AFURLConnectionOperation<NSURLConnectionDataDelegate>
类的任何钩子来扩展它的NSURLConnectionDataDelegate
的实现,这是非常必要的我相信实现一个下载进度HUD。
我喜欢做的事情是这样的:
RKObjectRequestOperation *operation =
[[RKObjectManager sharedManager]
appropriateObjectRequestOperationWithObject:nil
method:RKRequestMethodGET path:_requestPath
parameters:_requestParameters];
operation.RKHTTPRequestOperation.onDidReceiveResponse = ^(void)(NSURLConnection *connection, NSURLResponse *response) {
// store response or at least its estimated length
_response = response; //OR AT LEAST
// show progress hud at 0 / length = 0%
_estimated = response.expectedContentLength;
[SVProgressHUD showProgress:0.0f];
}
operation.RKHTTPRequestOperation.onDidReceiveData = ^(void)(NSURLConnection *connection, NSData *data) {
// show updated progress
[_myData appendData:data];
[SVProgressHUD showProgress:((float)myData.length/_estimated * 100)];
}
所以,我想知道:
是否有一个钩子/协议/块/选择器/我不知道RestKit
或AFNetworking
提供什么来实现这一点? (我看到的只有success
和failure
,这些都太晚了,无法使用。)
如果没有,最合适,可维护和安全的方法是调整/覆盖/修改NSURLConnectionDataDelegate
回调以将其公开给我的客户?