Open zhaoxianxin opened 3 months ago
struct DSBaseResponse: Mappable { init?(map: Map) { }
var code = 0 private var msg: String? var data: T? /// 适配没有套到data层中 var total = 0 var rows: T? mutating func mapping(map: Map) { msg <- map["message"] total <- map["total"] code <- map["code"] rows <- map["rows"] data <- map["data"] }
}
T maybe is Any,[T], [String, Any],Int ... I cannot let T must confirm protocol Mappable, such as :
struct DSBaseResponse: Mappable { }
how can I design this struct? like HandyJSON, HandyJSON can use like this.
// test let res = .... network response string let result = DSBaseResponse(JSONString: res.string)
struct DSBaseResponse: Mappable {
init?(map: Map) {
}
}
T maybe is Any,[T], [String, Any],Int ... I cannot let T must confirm protocol Mappable, such as :
struct DSBaseResponse: Mappable {
}
how can I design this struct? like HandyJSON, HandyJSON can use like this.
// test let res = .... network response string let result = DSBaseResponse(JSONString: res.string)