在尝试加载Webview时出现此错误。
class Root<T>: Decodable where T: SPTBaseObject {
let items: [T]
private struct CodingKeys: CodingKey {
var stringValue: String
init?(stringValue: String) {
self.stringValue = stringValue
}
var intValue: Int?
init?(intValue: Int) {
return nil
}
}
required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
guard let key = T.pluralKey, let codingKey = CodingKeys(stringValue: key) else {
fatalError()
}
items = try container.decode([T].self, forKey: codingKey)
}
}