ios - how to download file with AFNetworking and store in document folder -


i want create 1 application download file internet , store in document folder. searching in google , site , understand use afnetworking better. in framework can show progessview show download status.

im new in afnetworking , want guide me , tell me code how create 1 application download file afnetworking , show progessview status download.

use uiprogressview

here in code progress uiprogressview used

filepath : path file saved[documents directory]

import

#import <afnetworking/afnetworking.h> 

and download

progress.progress = 0.0;  currenturl=@"http://www.selab.isti.cnr.it/ws-mate/example.pdf";   nsurlrequest *request = [nsurlrequest requestwithurl:[nsurl urlwithstring:currenturl]]; afurlconnectionoperation *operation =   [[afhttprequestoperation alloc] initwithrequest:request];  nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *filepath = [[paths objectatindex:0] stringbyappendingpathcomponent:@"my_filename_with_extention.pdf"]; operation.outputstream = [nsoutputstream outputstreamtofileatpath:filepath append:no];  [operation setdownloadprogressblock:^(nsinteger bytesread, nsinteger totalbytesread, nsinteger totalbytesexpectedtoread) {     progress.progress = (float)totalbytesread / totalbytesexpectedtoread;  }];  [operation setcompletionblock:^{     nslog(@"downloadcomplete!");  }]; [operation start]; 

Comments