Objectmapper: Mapping dates

Created on 18 Oct 2016  路  4Comments  路  Source: tristanhimmelman/ObjectMapper

Hi there,

I'm trying to map a NSDate, like this:

...
var date : NSDate?
...
func mapping(map: Map) {
        date <- (map["date"], DateTransform())
    }

But it fails and I'm left with:

Binary operator '<-' cannot be applied to operands of type 'NSDate?' and '(map, DateTransform)'

Most helpful comment

Got this solved, using Date() instead of NSDate did it, thanks!

All 4 comments

@Dbigshooter, if you're using Swift 3, you should use Date instead of NSDate.

@devxoul Just changed it, compiles now, but still leaves null in my object date property.

@Dbigshooter please provide us the JSON dictionary

Got this solved, using Date() instead of NSDate did it, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danyalaytekin picture danyalaytekin  路  4Comments

patchthecode picture patchthecode  路  3Comments

VictorAlbertos picture VictorAlbertos  路  3Comments

nashirox picture nashirox  路  4Comments

zhengying picture zhengying  路  4Comments