Skip to content

Instantly share code, notes, and snippets.

@akring
Created June 6, 2017 06:07
Show Gist options
  • Save akring/1b3f9dd37fb9a0f9f90ffddc0c892eb6 to your computer and use it in GitHub Desktop.
Save akring/1b3f9dd37fb9a0f9f90ffddc0c892eb6 to your computer and use it in GitHub Desktop.
ObjectMapper 数据转换范例(Int <==> String)
let intTransform = TransformOf<String, Int>(fromJSON: { (value: Int?) -> String? in
// transform value from String? to Int?
if let value = value {
return String(value)
}
return nil
}, toJSON: { (value: String?) -> Int? in
// transform value from Int? to String?
return Int(value!)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment