I am making an app that downloads PDF File on button click and save it on locally through the app's sandbox.
Now, I want to put a progress bar during the download, how will I able to do that?
I have managed to do the downloading and viewing of the the file with this code...
Storing Data:
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://mywebsite.com/products/download/file.pdf"]];
NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
filePath = [resourceDocPath stringByAppendingPathComponent:@"myPDF.pdf"];
[pdfData writeToFile:filePath atomically:YES];
File View:
UIWebView *pdfFileView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
pdfFileView.delegate = self;
pdfFileView.backgroundColor = [UIColor clearColor];
pdfFileView.opaque = NO;
pdfFileView.userInteractionEnabled = YES;
[self.view addSubview:pdfFileView];
NSURL *url = [NSURL fileURLWithPath:filePath];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[pdfFileView loadRequest:requestObj];