在Swift中对`Any`类型的属性进行解码和编码

时间:2019-06-04 15:24:45

标签: ios swift core-data codable

我有一个名为Cast from '_?' to unrelated type 'MySwitch' always fails

的课程
SPEFormFieldData

我一声明财产就可以吗?它给我一个错误

类型“ SPEFormFieldData”不符合协议“可解码”

类型“ SPEFormFieldData”不符合协议“可编码”

我如何解析Any类型并符合Codable,我想将其实现为类,并且必须限制为import Foundation class SPEFormFieldData: NSObject, Codable { public var fieldType: String? public var fieldDescription: String? public var fieldValue: Any? public var fieldTitle: String? public var fieldKey: String? override init() { self.fieldValue = "" super.init() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") }

0 个答案:

没有答案