onevcat / Kingfisher

A lightweight, pure-Swift library for downloading and caching images from the web.
MIT License
23.4k stars 2.66k forks source link

DownsamplingImageProcessor ambiguous without more context #1244

Open dudisitchy opened 5 years ago

dudisitchy commented 5 years ago

Hi there,

My code below shows an error in options: [] of the setImage function: "Type of expression is ambiguous without more context" This is inside a cellForRowAt.

ImageCache.default.retrieveImage(forKey: listUsers[indexPath.row].cPicture) { result in
                        switch result {
                        case .success(let value):
                            switch value {
                            case .none:
                                print("no cache")
                            case .disk:
                                DispatchQueue.main.async {
                                    cell.iv_picture.kf.setImage(with: value, options: [
                                        .processor(DownsamplingImageProcessor(size: CGSize(width: 50, height: 46)))])
                                }
                            case .memory:
                                DispatchQueue.main.async {
                                    cell.iv_picture.kf.setImage(with: value, options: [
                                        .processor(DownsamplingImageProcessor(size: CGSize(width: 50, height: 46)))])
                                }
                            }
                        case .failure(let error):
                            print(error)
                        }
                    }

What am I doing wrong? I tried a lot of options in the wiki.

Thanks a lot!

onevcat commented 5 years ago

The type of value in your code is an ImageCacheResult. I guess you cannot set it as a parameter of kf.setImage, unless you have your own version. I suspect this causes the ambiguous. I believe it would be a good idea to check the error detail to see what exactly causes it.