Wrap icon indicating copy to clipboard operation
Wrap copied to clipboard

Added ability to fallback nil values

Open hebertialmeida opened this issue 6 years ago • 0 comments

This is the reborn of #36, as it was closed and I think it is relevant. Some APIs require sending null values for properties, this approach is interesting because keep the JSON clean and you can only override the ones you need.

Like:

struct Image: WrapCustomizable {
    let name
    let path: String?

    fileprivate func fallbackValueForProperty(propertyNamed propertyName: String) -> Any? {
        if propertyName == "path" {
            return NSNull()
        }
        return nil
    }
}

will wrap to a JSON like this:

{
    "name": "image.jpg",
    "path": null
}

hebertialmeida avatar Mar 16 '18 18:03 hebertialmeida