Note that there are some explanatory texts on larger screens.

plurals
  1. POIOS - Download file then showing it on UIWebView
    primarykey
    data
    text
    <p>I have a code that downloads a file and store it in the documents folder:</p> <pre><code>NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:file.url]]; AFURLConnectionOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory, file.name]; operation.outputStream = [NSOutputStream outputStreamToFileAtPath:filePath append:NO]; [operation start]; </code></pre> <p>When the request is completed, I want to show that same file on a UIWebView using this code:</p> <pre><code>[operation setCompletionBlock:^{ dispatch_sync(dispatch_get_main_queue(), ^{ UIWebView* webView = [[UIWebView alloc] init]; NSURL *targetURL = [[NSBundle mainBundle] URLForResource:file.nameWithoutExtension withExtension:@"pdf"]; webView.delegate = self; NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; [webView loadRequest:request]; ViewerVC* viewer = [[ViewerVC alloc] init]; [viewer.view addSubview:webView]; [self.navigationController pushViewController:viewer animated:FALSE]; }); }); </code></pre> <p>But it does not work, the URL does not find the file I just downloaded, Am i saving or searching it wrong?</p> <p>(The code is slightly different from my actual code for understanding purposes, but the idea is the same. I even tried this example with some hard coded URL, like: <a href="http://www.selab.isti.cnr.it/ws-mate/example.pdf" rel="nofollow">http://www.selab.isti.cnr.it/ws-mate/example.pdf</a>)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload