Skip to content

Instantly share code, notes, and snippets.

@DmitryVarennikov
Last active December 23, 2015 21:17
Show Gist options
  • Save DmitryVarennikov/0ea9975939eac9d3939d to your computer and use it in GitHub Desktop.
Save DmitryVarennikov/0ea9975939eac9d3939d to your computer and use it in GitHub Desktop.
```swift
UIApplication.sharedApplication().networkActivityIndicatorVisible = true
when(getQuestions(session.id, date: date), getAnswers(session.id, date: date)).then {
(questions: [SessionQuestion], answers: [SessionAnswer]) -> Void in
self.sessionQuestions = questions
self.sessionAnswers = answers
self.tableView.reloadData()
}.always {
UIApplication.sharedApplication().networkActivityIndicatorVisible = false
}
.error({ (error: ErrorType?) -> Void in
if let error = error as? PromiseKit.Error {
switch error {
case PromiseKit.Error.When(_, let errorType):
switch errorType {
case ServerError.Unauthorized:
print("ServerError.Unauthorized")
if let navigationController = self.navigationController as? ClientNavigationController {
dispatch_async(dispatch_get_main_queue()) {
navigationController.logOut()
}
}
default:
print("ServerError.Failure")
}
default :
print("default")
}
}
})
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment