Evening, I'm trying to set an ImageView.image (an IBOutlet in this case) with an image downloaded from the web.
I've already ridden a lot of questions about this in stack overflow.
And I've found this common answer:
NSURL *url = [NSURL URLWithString:@"http://www.fnordware.com/superpng/pnggrad16rgb.png"];
NSData *data = [NSData dataWithContentsOfURL:url];
NSLog(@"imageData: %@", data);
UIImage *image = [UIImage imageWithData:data];
NSLog(@"image: %@", image);
self.imageView.image = image;
I believe you are trying to run it on iOS 8 +
Please add this to your info.plist
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
And everything should be fine :)
iOS 8 onwards http is not allowed you have to use either https or add exception to your info.plist :)