2

I imported Kingfisher

 import UIKit
 import Kingfisher
    

This is my simple code to can explain the problem
Creating an imageView and trying display image from URL

class ViewController: UIViewController {

    @IBOutlet weak var image:UIImageView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let rawstring = "https://apis.baytelhekma.com/zinzo/public/storage/" + #"products\November2020\eUWwRjNCYCdHUjGIQiJk.png"#
        
        let url = URL(string: rawstring)
        image.kf.setImage(with: url)

       
    }


}
  • Do not use only `setImage(with:)` use the method with the completion handler that might return an error which might give more info about why it failed: https://github.com/onevcat/Kingfisher/blob/2a6d1135af3915547c4b08c3b154a05e6f1075a3/Sources/Extensions/ImageView%2BKingfisher.swift#L82 – Larme Dec 02 '20 at 17:22
  • failure(Kingfisher.KingfisherError.imageSettingError(reason: Kingfisher.KingfisherError.ImageSettingErrorReason.emptySource)) This is the output also URL isn't empty you can check it https://apis.baytelhekma.com/zinzo/public/storage/products\November2020\eUWwRjNCYCdHUjGIQiJk.png – Ahmad Aboelghet Dec 02 '20 at 17:55

2 Answers2

2

Please check your url again as I've tried another url and it works fine, you can check it:

import UIKit
import Kingfisher
class ViewController: UIViewController {

    @IBOutlet weak var image:UIImageView!
    let rawstring = "https://i.insider.com/5e820b04671de06758588fb8?width=700&format=jpeg&auto=webp"

        override func viewDidLoad() {
            super.viewDidLoad()
            
            
            let url = URL(string: rawstring)
            image.kf.setImage(with: url)

           
        }

}

or you can make url like this if it helped:

 let rawstring = "https://apis.baytelhekma.com/zinzo/public/storage/products/November2020/eUWwRjNCYCdHUjGIQiJk.png"
Menaim
  • 937
  • 7
  • 28
0

The problem is incorrect url, your're using \ in address.

So

let rawstring = "https://apis.baytelhekma.com/zinzo/public/storage/" + #"products\November2020\eUWwRjNCYCdHUjGIQiJk.png"

provides

https://apis.baytelhekma.com/zinzo/public/storage/products\November2020\eUWwRjNCYCdHUjGIQiJk.png

which is incorrect url


Changing it to

let rawstring = "https://apis.baytelhekma.com/zinzo/public/storage/" + #"products/November2020/eUWwRjNCYCdHUjGIQiJk.png"#

or simply to

let rawString = "https://apis.baytelhekma.com/zinzo/public/storage/products/November2020/eUWwRjNCYCdHUjGIQiJk.png"

will fix your issue

Mikhail Vasilev
  • 720
  • 6
  • 13