Added download progress

This commit is contained in:
Sergej Tatarincev
2011-09-28 12:23:28 +03:00
parent 2d281e60d3
commit 3983bd00f8
2 changed files with 8 additions and 0 deletions

View File

@@ -444,6 +444,11 @@ typedef enum {
*/
- (void)request:(RKRequest *)request didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
/**
* Sent when request has received data from remote site
*/
- (void)request:(RKRequest*)request didReceivedData:(NSInteger)bytesReceived totalBytesReceived:(NSInteger)totalBytesReceived totalBytesExectedToReceive:(NSInteger)totalBytesExpectedToReceive;
/**
* Sent to the delegate when a request was cancelled
*/

View File

@@ -187,6 +187,9 @@ extern NSString* cacheURLKey;
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[_body appendData:data];
if ([[_request delegate] respondsToSelector:@selector(request:didReceivedData:totalBytesReceived:totalBytesExectedToReceive:)]) {
[[_request delegate] request:_request didReceivedData:[data length] totalBytesReceived:[_body length] totalBytesExectedToReceive:_httpURLResponse.expectedContentLength];
}
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)response {