0

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.

3
  • In Swift 4, ObjectMapper is no longer needed. You can create your own mapping directly using the Codable protocol. Commented May 14, 2018 at 16:44
  • so, ObjectMapper stopped working for swift 4? because if i have to make the change i will have to change a lot of lines, or is still usable? if it is still usable, is there a way to fix my problem? Commented May 14, 2018 at 16:53
  • I don't know whether it stopped working; I'm just saying that there's now a simpler way, with no reliance on external pods. Commented May 14, 2018 at 16:57

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.