Skip to content

Instantly share code, notes, and snippets.

@JoelJWest
Created June 20, 2016 17:35
Show Gist options
  • Save JoelJWest/5d6296f1141ad506d0b7a28340a5e4ff to your computer and use it in GitHub Desktop.
Save JoelJWest/5d6296f1141ad506d0b7a28340a5e4ff to your computer and use it in GitHub Desktop.
- (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