imageView does't show the image with Swift 3 and Xcode 8


(Yue Cui) #1

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