0

I'm trying to load an image obtained from JSON response into tableView with the help of Kingfisher library. this is the image obtained from JSON response:

"image": "/static/restaurants/image-1593600873191.jpg"

Now I'm writing this code in cellForRow method :

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
     let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TableViewCell
        cell.lblName.text = arrUsers[0].data?.categories[0].name
        let url = URL(string:arrUsers[0].data?.bestOffers[0].image ?? "No Url")
       cell.imgName.kf.setImage(with: url)
        return cell
      }

In the above code, I'm converting the JSON response of the image into a URL and then passing it into setImage method.

The label is being set into tableView but the image isn't being loaded into tableViewCell and I'm getting this error in the console. please find attached the screenshot for refernce.

Menaim
  • 937
  • 7
  • 28
Viprottam
  • 1
  • 2

1 Answers1

0

Change this line:

let url = URL(string:arrUsers[0].data?.bestOffers[0].image ?? "No Url")

To

let url = URL(string: "https://yourwebsiteaddress" + (arrUsers[0].data?.bestOffers[0].image ?? "No Url"))
Teddichiiwa
  • 735
  • 6
  • 8