Skip to content

Instantly share code, notes, and snippets.

@macbaszii
Last active August 17, 2016 11:11
Show Gist options
  • Save macbaszii/f9d22a73e6aab0289e3f0930ce778ab9 to your computer and use it in GitHub Desktop.
Save macbaszii/f9d22a73e6aab0289e3f0930ce778ab9 to your computer and use it in GitHub Desktop.
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