[swift-dev] imageView does't show the image with Swift 3 and Xcode 8

Yue Cui cuiyue at msu.edu
Wed Oct 19 15:44:02 CDT 2016


I recently migrated my app to Swift 3 and Xcode 8.

The imageView didn't show the image if I re-open the app.

I used viewWillAppear() for this function. The code is as below:

let imageUrl: NSURL = NSURL(string: "\(userDefaults.string(forKey:
"avatar_url")!)")!
let imageData:NSData = NSData(contentsOf: imageUrl as URL)!
let logo = UIImage(data: imageData as Data)!
self.logoImage.image = logo

Any thoughts?

Thanks in advance.

Yue Cui


More information about the swift-dev mailing list