Since the latest release (2.2.4), Int64s are only mapped correctly if the variable is an IUO (Int64!). It does not map optional (Int64?) or non-optional Int64s. Until 2.2.3 it used to work without problem.
let myJSONDictionary: [String: Any] = [
"64BitInt": Int64(123),
"64BitIUOInt": Int64(321),
"64BitNonOptionalInt": Int64(456),
"regularInt": 654
]
class Item: Mappable {
var my64BitInt: Int64?
var my64BitIOUInt: Int64!
var my64BitNonOptionalInt: Int64 = 0
var regularInt: Int?
required init(map: Map) {
mapping(map: map)
}
func mapping(map: Map) {
my64BitInt <- map["64BitInt"]
my64BitIOUInt <- map["64BitIUOInt"]
my64BitNonOptionalInt <- map["64BitNonOptionalInt"]
regularInt <- map["regularInt"]
}
}
let item = Mapper<Item>().map(JSON: myJSONDictionary)
I exepected something like:
Item(my64BitInt: 123, my64BitIOUInt: 321, my64BitNonOptionalInt: 456, regularInt: 654)
Item(my64BitInt: nil, my64BitIOUInt: 321, my64BitNonOptionalInt: 0, regularInt: 654) // expected the Int64? and Int64 is mapped correctly.
Oh god, this is my fault. I'll check this right now. I apologize for my mistake!
Just created a new release with this fix. See 2.2.5
Thanks!! Awesome this quick response @devxoul and @tristanhimmelman. You're the best!
Most helpful comment
Thanks!! Awesome this quick response @devxoul and @tristanhimmelman. You're the best!