The newer RestKit
0.2.x is great but I cannot find any hook out of the RKHTTPRequestOperation : AFHTTPRequestOperation : AFURLConnectionOperation<NSURLConnectionDataDelegate>
class to extend it's implementation of NSURLConnectionDataDelegate
, which is quite necessary I believe to implement a download progress HUD.
What I would like to do is something like this:
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)];
}
So, I'd like to know:
Is there a hook/protocol/block/selector/whatever I am not aware of that
RestKit
orAFNetworking
provides to make this possible? (All I see issuccess
andfailure
, which are both too late to be of use).If not, what is the most appropriate and maintainable and safe way to swizzle/override/modify the
NSURLConnectionDataDelegate
callbacks to expose them to my client?