美文网首页
调用Kingfisher的setImage方法报Contextu

调用Kingfisher的setImage方法报Contextu

作者: 俺不是大佬儿 | 来源:发表于2023-10-30 15:35 被阅读0次

近日从Xcode14.3升级到了Xcode15.0.1出现了一系列的问题,做个记录

Contextual closure type '(Result<RetrieveImageResult, KingfisherError>) -> Void' expects 1 argument, but 4 were used in closure body 错误引出的Xcode 15 多行格式化 新功能

这是Kingfisher 的 setImage 方法的调用,更新

let imgUrl = URL(string: cellData as? String ?? "p_img_gray128_icon")
        
markImgView.kf.setImage(with: imgUrl, 
                                placeholder: UIImage.imgName("p_img_gray128_icon"),
                                options:[.transition(.fade(1))]) { receivedSize, totalSize in
            
} completionHandler: { image, error, cacheType, imageURL in
            
}
报错示例

修改结果

        let imgUrl = URL(string: cellData as? String ?? "p_img_gray128_icon")
        
        markImgView.kf.setImage(with: imgUrl, 
                                placeholder: UIImage.imgName("p_img_gray128_icon"),
                                options:[.transition(.fade(1))]) { receivedSize, totalSize in
            
        } completionHandler: { result in//回调结果是个枚举类型
            
            switch result {
            case .success(let imgResult):
                
            break
                
            case .failure(let error):
                
                break
            }
        }

多行格式化示例

Xcode15多行格式化

相关文章

网友评论

      本文标题:调用Kingfisher的setImage方法报Contextu

      本文链接:https://www.haomeiwen.com/subject/bnwyidtx.html