使用 '!'不推荐使用,在以后的发行版中将其删除-swift 4.2 [英] Using '!' here is deprecated and will be removed in a future release - swift 4.2
本文介绍了使用 '!'不推荐使用,在以后的发行版中将其删除-swift 4.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Swift 4.2中使用SDWebimage在单元格中设置图像时,编译器会引发以下警告.
Compiler throwing following warning when setting image in a cell using SDWebimage in Swift 4.2.
快速编译器警告:
使用'!'这里已弃用,并将在以后的版本中删除
let url = NSURL(string: (str_url) as String)
cell.img!.sd_setImage(with: url as URL!, completed: block_image) //--- WARNING ON THIS LINE AT URL!
有什么建议吗?
推荐答案
使用以下代码:cell. img!.sd_setImage(with: url! as URL, completed: block_image)
建议:使用URL
代替NSURL
let url = URL(string: "" ) //use url String
cell.img!.sd_setImage(with: url, completed: block_image)
这篇关于使用 '!'不推荐使用,在以后的发行版中将其删除-swift 4.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文