Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
extension Person: DefaultConvertible {
private static let firstNameKey = "first_name"
private static let lastNameKey = "last_name"
private static let ageKey = "age"
var serialized: [String : AnyObject] {
Person.firstNameKey: firstName as AnyObject,
Person.lastNameKey: lastName as AnyObject,
Person.ageKey: age as AnyObject
init?(dictionary: [String : AnyObject])
guard let firstName = dictionary[Person.firstNameKey] as? String,
let lastName = dictionary[Person.lastNameKey] as? String,
let age = dictionary[Person.ageKey] as? Int
else { return nil }
self.firstName = firstName
self.lastName = lastName
self.age = age
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.