tristanhimmelman / AlamofireObjectMapper

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

Mapping of Array Response With Modle name as string #268

Open MahmoudEmarah opened 5 years ago

MahmoudEmarah commented 5 years ago

Hello, Is there any way to map an response array to an object only by it's name as string for example: let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/f583be1121dbc5e9b0381b3017718a70c31054f7/sample_array_json" Alamofire.request(URL).responseArray { (response: DataResponse<[Forecast]>) in

let forecastArray = response.result.value

if let forecastArray = forecastArray {
    for forecast in forecastArray {
        print(forecast.day)
        print(forecast.temperature)           
    }
}

} if I have Forecast as String "Forecast" can I do it.