显示到tableview的JSON
我想第一次使用AlamoFileObjectMapper来解析swift中的json响应。 我将其映射如下:显示到tableview的JSON,json,swift,uitableview,objectmapper,Json,Swift,Uitableview,Objectmapper,我想第一次使用AlamoFileObjectMapper来解析swift中的json响应。 我将其映射如下: class ModelCurrency: Mappable { var success : Bool? var terms : String? var privacy : String? var timestamp : CGFloat? var source : String? var quotes : [Quot
class ModelCurrency: Mappable {
var success : Bool?
var terms : String?
var privacy : String?
var timestamp : CGFloat?
var source : String?
var quotes : [Quotes]?
init() {}
required init?(map: Map) {
}
func mapping(map: Map) {
success<-map["success"]
terms<-map["terms"]
privacy<-map["privacy"]
timestamp<-map["timestamp"]
source<-map["source"]
quotes<-map["quotes"]
print("It json\(terms)")
}
}
class Quotes : Mappable {
var name : String?
var val : CGFloat?
required init?(map: Map) {
}
func mapping(map: Map) {
name<-map["name"]
val<-map["val"]
}
}
类模型货币:可映射{
var成功:布尔?
var术语:字符串?
var隐私:字符串?
var时间戳:CGFloat?
变量源:字符串?
变量引号:[引号]?
init(){}
必需的初始化?(映射:映射){
}
func映射(映射:映射){
成功我认为在更新数据源阵列表之后需要查看表:
...
for quotes in currency.quotes! {
self.arrayTable.append(quotes.name!)
}
self.tableView.reloadData()
...
此外,您不需要调用super.viewDidLoad()
两次。我认为您需要在更新数据源数组表之后调用表视图:
...
for quotes in currency.quotes! {
self.arrayTable.append(quotes.name!)
}
self.tableView.reloadData()
...
此外,您不需要调用super.viewDidLoad()
两次