tristanhimmelman / AlamofireObjectMapper

An Alamofire extension which converts JSON response data into swift objects using ObjectMapper
MIT License
2.66k stars 474 forks source link

How can I handle case where i Need to handle same value with diffrent keys? #218

Open santhoshs5 opened 7 years ago

santhoshs5 commented 7 years ago

class User:Mappable { dynamic var name:Srtring? dynamic var players:List()

func mapping(map: Map) { name <- map["name"] players <- (map["players"] ,listTransform()) // this key can be friends in other scenarion but need to map same Player object . } }

How can I acheive this .?

Shanlon commented 7 years ago

You could do something like: if let players = map.JSON["players"] { // Set values } else if let friends = map.JSON["friends"] { // Set values }