【发布时间】:2018-12-31 00:29:52
【问题描述】:
我正在使用这个库,https://github.com/gcharita/XMLMapper。
它包含协议,
public protocol XMLBaseMappable {
var nodeName: String! { get set }
}
我想将这个 nodeName 设为可选,用于实现它的结构/类,例如
public protocol CustomXMLBaseMappable {
var nodeName: String? { return "default" }
//I don't want struct/classes using it, implements `nodeName`.
}
任何建议都会有所帮助。
【问题讨论】:
-
No 你不能改变协议的定义。
-
您有这样做的理由吗?我问这个是因为这个属性的实现对于库的正确运行非常重要。
-
@gcharita 就我而言,我必须使用 Pod 对第三方库的类/结构进行编码。由于扩展不能包含存储属性,
nodeName给我带来了麻烦。救命!!
标签: ios swift xml codable xmlmapper