I am saving the image url successfully from an api and am having issues showing it when I run the app. avatarString has the correct url but as soon as I get to the next line I keep getting:
fatal error: unexpectedly found nil while unwrapping an Optional value
My avatarData var is returning as nil. I don't know what why. Running Xcode Beta 6.3. Thanks for any help.
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
var avatarString = NSURL(string: self.userInfo.avatarURL)!
var avatarData = NSData(contentsOfURL: avatarString, options: nil, error: nil)
var avatarImage = UIImage(data: avatarData!)
self.avatarImage.image = avatarImage
})
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…