Updated 14 December 2016
On iPhone you can’t save the pdf/doc file. But you can create your own storage area in your ios application to store and show the pdf and doc file.Put url data in NSData then write a file to the document directory after that you can use your file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
NSURL *url = [NSURL URLWithString:stringURL]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filename = [NSString stringWithFormat:@"filename.pdf"]; filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,filename]; BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filePath]; if (fileExists) { // do your stuff } else { NSData *urlData = [NSData dataWithContentsOfURL:url]; [urlData writeToFile:filePath atomically:YES]; [self performSegueWithIdentifier:@"downloadToFiles" sender:self]; } NSURL *urlen = [NSURL fileURLWithPath:_filepath]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:urlen]; [_webView loadRequest:urlRequest]; |
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.