Compiler throwing following warning when setting image in a cell using SDWebimage in Swift 4.2.
Swift Compiler warning :
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!
Any Suggestions ?
Use this code : cell. img!.sd_setImage(with: url! as URL, completed: block_image)
Suggestion: use URL
instead of NSURL
let url = URL(string: "" ) //use url String
cell.img!.sd_setImage(with: url, completed: block_image)