Search code examples
iosswiftobjectmapper

ObjectMapper array error


I have this json:

    Optional(<__NSSingleObjectArrayI 0x600000016530>(
{
    direccion = "";
    geo =     {
        coordinates =         (
            "25.65313",
            "-100.3611"
        );
        type = "";
    };
    nombre = "Mi Ubicacion";
}
)
)

and my model is this:

class LocationModel: Mappable {
    var nombre = ""
    var direccion = ""
    var geo = GeoModel()

    init(){

    }

    required init?(map: Map) {

    }

    // Mappable
    func mapping(map: Map) {
        nombre <- map["nombre"]
        direccion <- map["direccion"]
        geo <- map["geo"]
    }

}

and this is how im mapping it:

locationsGuardadas = Mapper<LocationModel>().mapArray(JSONArray: locationsJson as! [[String : Any]])

that code worked fine until a few days ago, when i updated my sdk to support ios 11.3, then the code stopped working, i have tried updating the objectmapper pod, and reseting simulator content and settings, but for some reason now, when i map the array, the "coordinates" array of the location comes without coordinates, it has a 0 count, and i dont know how to fix this problem, any help will be appreciated.


Solution

  • I have already found the problem, for some reason the ObjectMapper doesn't work well with float numbers, so changing every float to double did the trick