The NSURL constructor you invoke received this signature:
convenience init?(string URLString: String)
? means that the constructor may not return a value, so it is considered optional .
The same goes for the NSData strong> constructor :
init?(contentsOfURL url: NSURL)
Quick fix:
let myProfilePictureURL = NSURL(string: "http://graph.facebook.com/bobdylan/picture") let imageData = NSData(contentsOfURL: myProfilePictureURL!) self.myImage.image = UIImage(data: imageData!)
The best solution is to check (expand) these options, even if you are sure that they contain a value!
More information about the options can be found here: link to Apple's official documentation .
source share