Muhammad Rehan
Muhammad Rehan

Reputation: 1

I am facing issues on Kingfisher library function to calling, images not show if I am commit some code

I have updated my Kingfisher library because of Xcode 15.0 requirement. After updating I am facing issues in function setImage method from Kingfisher directly on the UIImageView.

Here is my code:

func setImage(fromURL url: String?, dominantColor: String? = "", placeholder: UIImage? = nil) {
    if let urlString = url, let url = URL(string: urlString) {
        var placeHolder = placeholder
        
        // Create the resource directly from the URL as a string
        let resource = ImageResource(name: urlString, bundle: Bundle.main)
        
        if let dominantColor = dominantColor, dominantColor.count > 0 {
            // Replace the following line with your color conversion code if needed
            self.backgroundColor = UIColor.white
        } else {
            placeHolder = UIImage(named: "placeholder")
        }
        
        // Use the setImage method from Kingfisher directly on the UIImageView
        self.kf.setImage(with: resource, placeholder: placeHolder, options: nil, completionHandler: { _ in
            self.backgroundColor = UIColor.white
        })
        
    } else {
        self.image = UIImage(named: "placeholder")
    }
}

I am facing this issue:

No exact matches in call to instance method 'setImage'.

on this method.

// Use the setImage method from Kingfisher directly on the UIImageView
self.kf.setImage(with: resource, placeholder: placeHolder, options: nil, completionHandler: { _ in
    self.backgroundColor = UIColor.white
})

Upvotes: 0

Views: 217

Answers (0)

Related Questions