title: Loading NSData into a UIWebView
body: <p>In my web browser, I am trying to load a <code>UIWebView</code> with <code>NSData</code> obtained from a <code>NSURLConnection</code>. When I try to load it into the <code>UIWebView</code>, instead of the site, it comes up with the HTML plain text.</p>
  
  <p><strong>Here is my code:</strong></p>
  
  <p>in <code>viewDidLoad:</code></p>
  
  <pre><code>NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString:@"http://www.msn.com"]];
  [NSURLConnection connectionWithRequest: request delegate:self];
  </code></pre>
  
  <p><strong>later in the code:</strong></p>
  
  <pre><code> -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
    {
       webdata = [NSMutableData dataWithData: data];
    }
  
   -(void)connectionDidFinishLoading:(NSURLConnection *)connection
    {
      [webview loadData:webdata MIMEType: @"text/html" textEncodingName: @"UTF-8" baseURL:nil];
    }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/R5lQz.png" alt="UIWebView loading plain HTML instead of loading the page"></p>