Nested objects are always coming nil.
Closed this issue · 1 comments
santhoshs5 commented
class UserInfo:Mappable
{
var name:String?
var identifier:String?
var accountType:String?
var devices:[UserDevice]?
required init?(map: Map) {
}
// Mappable
func mapping(map: Map) {
name <- map["username"]
identifier <- map["identifier"]
accountType <- map["accountType"]
devices <- map["devices"]
}
}
class UserDevice:Mappable
{
var deviceName:String?
var deviceType:String?
var deviceIdentifier:String?
required init?(map: Map) {
}
// Mappable
func mapping(map: Map) {
deviceName <- map["name"]
deviceType <- map["type"]
deviceIdentifier <- map["identifier"]
}
}
Alamofire.request(request).responseObject{response in
let user = response.result.value
}
This is my code my userdevices is coming nil always
tristanhimmelman commented
This looks like it should work to me. Please include a JSON sample so that we can help you better. I will close this ticket for now until you reply.