Progress bar when downloading iOS files

I use the following files to download files from the Internet:

NSData *myXMLData1 = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"Link]];

Now I want to put a progress bar at boot time. I checked various posts, but I can’t find out exactly how to do this.

Please help me!

+6
source share
2 answers

I would recommend a look at the ASIHTTP library, which contains many useful classes for handling mobile messages and loading.

Here is a link where they describe what ASIHTTP has to offer in terms of tracking download progress: http://allseeing-i.com/ASIHTTPRequest/How-to-use#progress

+8
source

add

 expectedBytes = [response expectedContentLength]; 

to

 -(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response 

and add

 float progress = ((_bytesReceived/(float)_expectedBytes)*100)/100; 

to

 -(void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data 

then setProgress: on your UIProgressView

From: http://www.developers-life.com/progress-bar-download-file-on-iphone.html

+8
source

Source: https://habr.com/ru/post/915077/


All Articles