Created
October 25, 2016 06:10
-
-
Save stremsdoerfer/0a9e7f8463b40c59fef5ec6a2bf720ad to your computer and use it in GitHub Desktop.
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
struct User:Mappable{ | |
let id:Int | |
let name:String | |
init(map: Mapper) throws { | |
self.id = try map.from("id") | |
self.name = try map.from("name") | |
} | |
} | |
... | |
myProvider.request(Route(path:"/user/1234")).responseObject { (response:Response<User>) in | |
switch response.result{ | |
case .success(let user): | |
print("success: user name is \(user.lastName)") | |
case .failure(let error): | |
print("error: \(error)") //Will print an error, if the User cannot be parsed. (if the User initializer has thrown an error) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment