Objectmapper: Problem with float values after update to Swift 4.1 Xcode 9.3

Created on 6 Apr 2018  ·  3Comments  ·  Source: tristanhimmelman/ObjectMapper

Hi, I was using a mappable model like this

struct BalanceData: Mappable {

    var balance = Float()

    init?(map: Map){
    }

    mutating func mapping(map: Map) {
        balance     <- map["balance"]
    }

}

And this is the response I am parsing into that model

{
  "status": 200,
  "message": "OK",
  "error": "",
  "data": {
    "balance": 797.76
  }
}

This was working just great until I update to Xcode 9.3 and macOS High Sierra this morning.
Now BalanceData.balance is getting 0 instead of 797.76, I have to change var balance = Float() to Double() in model in order to get the correct value.

Most helpful comment

we just changed our Floats to Doubles

All 3 comments

we just changed our Floats to Doubles

This was quite a suprising bug! Also on Swift 4.1/XCode 9.3 here, and the app just completely stopped working because of this o_O

We also have a large number of Mappable objects and now I am sitting here and wondering are there more things that are broken? Did I find all the floats?

Hi, I just merged a PR which should address this issue. Please see v3.2.0

Was this page helpful?
0 / 5 - 0 ratings