Skip to content

Instantly share code, notes, and snippets.

@salverde
Last active February 8, 2017 04:21
Show Gist options
  • Save salverde/2953a49d33fb85a60d1e13f502a9bea4 to your computer and use it in GitHub Desktop.
Save salverde/2953a49d33fb85a60d1e13f502a9bea4 to your computer and use it in GitHub Desktop.
Unbox example
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