Created
June 6, 2017 06:07
-
-
Save akring/1b3f9dd37fb9a0f9f90ffddc0c892eb6 to your computer and use it in GitHub Desktop.
ObjectMapper 数据转换范例(Int <==> String)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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