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 ofNSURL
Try this: