使用 '!'这里已被弃用,将在未来的版本中删除 - swift 4.2
Using '!' here is deprecated and will be removed in a future release - swift 4.2
在 Swift 4.2.
中使用 SDWebimage 在单元格中设置图像时,编译器抛出以下警告
Swift 编译器警告:
Using '!' here is deprecated and will be removed in a future release
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)
试试这个:
if let url = URL(string: str_url) {
cell.img!.sd_setImage(with: url, completed: block_image)
}
在 Swift 4.2.
中使用 SDWebimage 在单元格中设置图像时,编译器抛出以下警告Swift 编译器警告:
Using '!' here is deprecated and will be removed in a future release
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)
试试这个:
if let url = URL(string: str_url) {
cell.img!.sd_setImage(with: url, completed: block_image)
}