Value of optional type 'UIImage?' not unwrapped; did you mean to use '!' or '?'?

swift 函数语法

Xcode 6.0 和 6.1 有初始化不一样的地方, UIImage相关的地方会报错: Value of optional type 'UIImage?' not unwrapped; did you mean to use '!' or '?'?

例如:

let image = UIImage(named: "lol")

imageView.image = image
可以改为
if let image = UIImage(named: "lol") {
  imageView.image = image

}

或者直接在后面加! : 

let image = UIImage(named: "lol")!
imageView.image = image


欢迎转载,转载请注明来自一手册:http://yishouce.com/article/96.html
友情链接It题库(ittiku.com)| 版权归yishouce.com所有| 友链等可联系 admin#yishouce.com|粤ICP备16001685号-1