Last active
February 8, 2017 04:21
-
-
Save salverde/2953a49d33fb85a60d1e13f502a9bea4 to your computer and use it in GitHub Desktop.
Unbox example
This file contains 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
import Foundation | |
import Unbox | |
struct Abuser { | |
let username: String | |
let fullName: String | |
let age: Int | |
let photos: [Photo]? | |
} | |
extension Abuser: Unboxable { | |
init(unboxer: Unboxer) throws { | |
self.username = try unboxer.unbox(key: "user_name") | |
self.fullName = try unboxer.unbox(key: "full_name") | |
self.age = try unboxer.unbox(key: "age") | |
self.photos = unboxer.unbox(key: "photos") | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment