Last active
August 17, 2016 11:11
-
-
Save macbaszii/f9d22a73e6aab0289e3f0930ce778ab9 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
typealias UserCompletionBlock = (user: User?, error: NSError?) -> () | |
func currentUser(withCompletionBlock completionBlock: UserCompletionBlock) { | |
Alamofire.request(Router.CurrentUser) | |
.responseObject(typeOfError: ExampleAPIError.self) { (response: Response<User, NSError>) in | |
switch response.result { | |
case .Success(let user): | |
completionBlock(user: user, error: nil) | |
case .Failure(let error): | |
completionBlock(user: nil, error: error) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment