freshOS / Arrow

🏹 Parse JSON with style
MIT License
387 stars 27 forks source link

Support optional data for custom models #4

Closed maxkonovalov closed 8 years ago

maxkonovalov commented 8 years ago

Hi! In some cases optional vars for custom models are needed in addition to plain swift types.

For example:

struct Profile {
    var identifier = 0
    var stats: Stats? = nil
}

extension Profile: ArrowParsable {
    init(json: JSON) {
        identifier <-- json["id"]
        stats <== json["stats"] // error
    }
}

The current implementation gives the following error for the above code: Cannot convert value of type 'Stats?' to expected argument type 'inout _'.