Note that there are some explanatory texts on larger screens.

plurals
  1. POOpen downloaded files in webview in iphone
    text
    copied!<p>I am new to iphone development. I am developing an iphone application in which i am downloading files using web service with following code:</p> <pre><code> NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *basePath = [paths objectAtIndex:0]; NSString *fileLoc = [basePath stringByAppendingString:@"/filename.pdf"]; NSData *fileData = [self decodeBase64WithString:soapResults]; [fileData writeToFile:fileLoc atomically:YES]; </code></pre> <p>And my file is in path : /Users/myusername/Library/Application Support/iPhone Simulator/4.0/Applications/7A627E64-DEAB-40FA-BE04-35ED50580B65/filename.pdf</p> <p>How can i open this file using uiwebview??? I tried this:</p> <pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *basePath = [paths objectAtIndex:0]; NSString *fileLoc = [basePath stringByAppendingString:@"/filename"]; [self loadDocument:fileLoc inView:mywebview]; </code></pre> <p>My loadDocument method is:</p> <pre><code>-(void)loadDocument:(NSString*)documentName inView:(UIWebView*)webView { NSString *path = [[NSBundle mainBundle] pathForResource:documentName ofType:@"pdf"]; NSURL *url = [NSURL fileURLWithPath:path]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webView loadRequest:request]; } </code></pre> <p>But it showing error... I think location is the problem.. How can i find the path in simulator as well as in orignal device???</p> <p>Please help me...</p>
 

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