The following code works to load a UIImage from a URL. However, when I try to load an image from Craigslist, the image does not work. I have verified the craigslist imagePath is working.
NSURL *imageURL = [NSURL URLWithString:@"http://images.free-extras.com/pics/c/car-530.jpg"];
NSData *data = [NSData dataWithContentsOfURL:imageURL];
UIImage *img = [[UIImage alloc] initWithData:data] ;
self.imageView.image = img;
I have tried this
NSURL *imageURL = [NSURL URLWithString:@"http://images.craigslist.org/3m23pb3l85T65R05S4b8462d2236c156a1ce3.jpg"];
NSData *data = [NSData dataWithContentsOfURL:imageURL];
UIImage *img = [[UIImage alloc] initWithData:data] ;
self.imageView.image = img;
and even this
NSString * urlString = [@"http://images.craigslist.org/3m23pb3l85T65R05S4b8462d2236c156a1ce3.jpg" stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL * imageURL = [NSURL URLWithString:urlString];
NSData *data = [NSData dataWithContentsOfURL:imageURL];
UIImage *img = [[UIImage alloc] initWithData:data] ;
self.imageView.image = img;
Any help is much appreciated. My Error message reads:
Error Domain=NSCocoaErrorDomain Code=256 "The operation couldn’t be completed. (Cocoa error 256.)
[NSData dataWithContentsOfURL:options:error:]
and seeing what error is returned? – highlycaffeinated<Foundation/FoundationErrors.h>
error 256 is theNSFileReadUnknownError
("Read error (reason unknown)"). So there is not too much information in that I'm afraid... – Mundi