Last active
December 23, 2015 21:17
-
-
Save DmitryVarennikov/0ea9975939eac9d3939d 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
```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