Last active
December 19, 2017 16:53
-
-
Save luisburgos/8abe7b696b6b6878ed58dc7d20f04dbb to your computer and use it in GitHub Desktop.
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
// | |
// User.swift | |
// YellowPod | |
// | |
// Created by Luis Burgos on 12/5/17. | |
// Copyright © 2017 Yellowme. All rights reserved. | |
// | |
import Foundation | |
import SwiftyJSON | |
struct User { | |
//HERE: Define all user variables | |
var email: String? = nil | |
var name: String? = nil | |
init(name: String, image: String) { | |
self.name = name | |
self.image = image | |
} | |
} | |
extension User: APIModel { | |
init(json: JSON) throws { | |
//HERE: - Map all variables. Go to "Networking+Keys" and define all your keys | |
//HERE: - 1. Validate keys you want | |
//try json.guarantee(hasKeys: .email, .name) | |
//HERE: - 2. Obtain values from keys | |
//guard let id = json.parse(.email).string else { throw Keys.email } | |
//guard let name = json.parse(.name).string else { throw Keys.name } | |
//HERE: - 3. Assign the parsed values | |
//self.id = id | |
//self.name = name | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment