-4

Help me! I want download a file. And how display progress bar?

I read a lot of articles and I do not work, do not work, you can explain to me how to do it?

  • http://stackoverflow.com/questions/4243910/how-to-display-progressbar-during-downloading-video-file-from-the-server-in-to-t – Davi Stuart Sep 27 '13 at 19:10

1 Answers1

1

You can get expected total file size in following callback method of NSURLconnection,

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
   expectedTotalSize = response.expectedContentLength;
}

then in the following callback method you can calculate how much data has been recieved,

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
   recievedData += data.length;
}

And you can use UIProgressView to show current downloading status on the screen.

Lance
  • 8,872
  • 2
  • 36
  • 47
Davi Stuart
  • 269
  • 3
  • 16
  • 1
    Just a guess, but he tagged his question with afnetworking-2 so I'm assuming he wants to use that library. – Lance Sep 27 '13 at 19:17