import Foundation public struct Images: Codable { public var otherData: [String: Data] = [:] mutating func setDetail(key: String, value: T) throws { let encodedValue = try JSONEncoder().encode(value) otherData[key] = encodedValue } func getDetail(key: String, type: T.Type) throws -> T? { guard let data = otherData[key] else { return nil } return try JSONDecoder().decode(type, from: data) } }