title: Cocoa Error 256, while retrieving data from web server in Objective C
body: <p>I have an application where I am sending image data on server through ftp and retrieving back in a functionality of preview. Now I am able to send the image on server,but while retrieving it back,I am getting following error in NSData and 0 bytes are fetched.</p>
  
  <blockquote>
    <p>Error Domain=NSCocoaErrorDomain Code=256 "The operation couldn\u2019t be completed. (Cocoa error 256.)"</p>
  </blockquote>
  
  <p>I am parsing data through XML and fetching the image url like this </p>
  
  <blockquote>
    <p><code>http://111.222.333.44/abc/images/User/img102-13.png</code> </p>
  </blockquote>
  
  <p>Now,when I use the following code to retrieve imgstr to nsdata, but getting the above error in the same. </p>
  
  <pre><code> NSURL *u = [NSURL URLWithString:imgstr];
   NSError *error;
   NSData *dt = [NSData dataWithContentsOfURL:u options:NSDataReadingMapped error:&amp;error];
   myImage = [UIImage imageWithData:dt];
  </code></pre>
  
  <p>I am able to fetch other data easily,but not the image data. Can anybody point out,where I am doing mistake or how I can resolve the problem? Thanks in advanced.</p>
  
  <p>EDIT : 
  In my application I am first of all capturing an image and storing it on the server. And then on the 2nd page,I need to fetch the image data and to show the same image when the user clicks a button called Preview. I am having a web service where I am getting the data including the path of the image as shown above,but with the method shown I am not able to fetch the Image data in NSData and getting the Cocoa error 256. Hope this help someone to show me a better and correct Path. Thanks.</p>