title: Strange error with initWithContentsOfURL
body: <p>I'm currently working on reading some XML from an external API.</p>
  
  <p>The following code works fine:</p>
  
  <pre><code>NSError *error = nil;
  
  NSString *xmlString = [[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&amp;error];
  </code></pre>
  
  <p>However, I wanted to add some error handling ("The server cannot be reached", "No Internet connection" etc). So, I put this block in place with a little help from the Reachability sample code:</p>
  
  <pre><code>if ([error code] == kCFURLErrorNotConnectedToInternet) {
          NSDictionary *userInfo = [NSDictionary dictionaryWithObject:NSLocalizedString(@"No Internet connection",@"Error message displayed when not connected to the Internet.") forKey:NSLocalizedDescriptionKey];
          NSError *noConnectionError = [NSError errorWithDomain:NSCocoaErrorDomain code:kCFURLErrorNotConnectedToInternet userInfo:userInfo];
          [self handleError:noConnectionError];
      } else {
          // otherwise handle the error generically
          [self handleError:error];
      }
  </code></pre>
  
  <p>The handleError method simply displays a UIAlertView with the error's details. When I ran the app with no connection, I expected to see my error message. However, all I ever get is "Operation could not be completed (Cocoa error 256)" which from what I can gather is a generic read error.</p>
  
  <p>At first I thought it might just be TouchXML's method, but as you can see I changed this to NSString's initWithCOntentsOfURL.</p>
  
  <p>Can anyone shed any light on this issue?</p>
  
  <p>Thanks,</p>
  
  <p>Rich</p>