Created
June 20, 2016 17:35
-
-
Save JoelJWest/5d6296f1141ad506d0b7a28340a5e4ff 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
| - (TOCFuture *)updateAccount { | |
| self.saveButton.enabled = NO; | |
| BGLManagedAccountEditor *const accountEditor = [self newAccountEditor]; | |
| [accountEditor setContributesToAggregateTotals:self.settingsSession.contributesToAggregateTotals]; | |
| [accountEditor setLowFundsAlertEnabled:self.settingsSession.lowBalanceAlertEnabled]; | |
| [accountEditor setLowFundsAlertThreshold:self.settingsSession.lowBalanceThreshold]; | |
| [accountEditor setAccountType:[BGLManagedAccount accountTypeForAccountClass:self.settingsSession.accountClass]]; | |
| [accountEditor setFavorited:self.settingsSession.favorite]; | |
| TOCFuture *accountFuture = [accountEditor persistUnless:nil]; | |
| MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; | |
| hud.labelText = NSLocalizedString(@"Loading", @"Loading label"); | |
| [accountFuture catchDo:^(id value) { | |
| [hud hide:YES]; | |
| [self.navigationController popViewControllerAnimated:YES]; | |
| }]; | |
| [accountFuture thenDo:^(id failure){ | |
| self.saveButton.enabled = YES; | |
| NSError *error = failure; | |
| UIAlertController *const alertController = [self createAlertControllerWithMessage:error.localizedDescription]; | |
| [hud hide:YES]; | |
| [self presentViewController:alertController animated:YES completion:nil]; | |
| }]; | |
| return accountFuture; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment