Closed oncity closed 8 years ago
json data {"dateline":123,"data":[{"tid":1466218037,"subject":"time is"},{"tid":123,"subject":"catcat"}]}
{"dateline":123,"data":[{"tid":1466218037,"subject":"time is"},{"tid":123,"subject":"catcat"}]}
class NewsNode: Mappable { var tid: Int? var subject: String? required init?(_ map: Map) { } func mapping(map: Map) { tid <- map["tid"] subject <- map["subject"] } } class BaseList<T>: Mappable { var dateline: Int? var data: [T]? required init?(_ map: Map) { } func mapping(map: Map) { dateline <- map["dateline"] data <- map["data"] } } Alamofire.request(.GET, URL).responseObject { (response: Response< BaseList<NewsNode>, NSError>) in let dd = response.result.value print(dd?.data) }
data is nil
if change to var data: [NewsNode]? is work
var data: [NewsNode]?
help
class BaseList<T:Mappable>: Mappable
json data
{"dateline":123,"data":[{"tid":1466218037,"subject":"time is"},{"tid":123,"subject":"catcat"}]}
data is nil
if change to
var data: [NewsNode]?
is workhelp