我有以下结构 . 前3个属性从JSON解码,第4个属性用作缓存,如果图像被下载 .
import UIKit
struct Thumbnail: Codable {
let url: String
let width: UInt
let height: UInt
var image: UIImage?
enum CodingKeys: String, CodingKey {
case url
case width
case height
}
}
当我尝试编译Xcode时告诉我,Thumbnail并不符合Codable,但据我所知,使用CodingKeys枚举应该忽略协议中的 image
?任何建议将不胜感激:)