title: iOS download and save HTML file
body: <p>I am trying to download a webpage (html) then display the local html that has been download in a UIWebView. </p>
  
  <p>This is what I have tried -</p>
  
  <pre><code>NSString *stringURL = @"url to file";
  NSURL  *url = [NSURL URLWithString:stringURL];
  NSData *urlData = [NSData dataWithContentsOfURL:url];
  if ( urlData )
  {
      NSArray       *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString  *documentsDirectory = [paths objectAtIndex:0];  
  
      NSString  *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"index.html"];
      [urlData writeToFile:filePath atomically:YES];
  }
  
      //Load the request in the UIWebView.
      [web loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]];        // Do any additional setup after loading the view from its nib.
  </code></pre>
  
  <p>But this gives a 'SIGABRT' error.</p>
  
  <p>Not too sure what I have done wrong?</p>
  
  <p>Any help would be appreciated. Thanks!</p>