Request delegate to monitor the download progress ?

512 views
Skip to first unread message

Frederic Visticot

unread,
Jun 2, 2012, 3:48:56 PM6/2/12
to res...@googlegroups.com
My app needs to download big files (> 200MB). 
1. I would like to display a progressView with the amount left for download. Is it available ? If  not how to do it ?
2. Is it possible for the download to specify a file as destination (and not read the NSData from the RKResponse body) ?

Tx for your help.

Fred

Nic Werner

unread,
Jun 2, 2012, 3:57:42 PM6/2/12
to res...@googlegroups.com
Use this delegate response:

- (void)request:(RKRequest*)request didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite{

 currentProgress = totalBytesWritten / (float)totalBytesExpectedToWrite;

}

For a working demo, look at the RK demo examples, I believe this is in the DiscussionBoard example.

Frederic Visticot

unread,
Jun 2, 2012, 4:40:15 PM6/2/12
to res...@googlegroups.com
Tx,
I have used the code bellow (I'm downloading content).
Any option to define the delegate callback period (or delta bytes). By default, this callback is called many times per second...

Fred

- (void)request:(RKRequest *)request didReceiveData:(NSInteger)bytesReceived totalBytesReceived:(NSInteger)totalBytesReceived totalBytesExpectedToReceive:(NSInteger)totalBytesExpectedToReceive

{

    double currentProgress = totalBytesReceived / (float)totalBytesExpectedToReceive;

    NSLog(@"Progress: %f", (currentProgress*100.0));    

}

Reply all
Reply to author
Forward
0 new messages