Skip to content

Instantly share code, notes, and snippets.

@simonpang
Created April 3, 2013 13:14
Show Gist options
  • Save simonpang/5301093 to your computer and use it in GitHub Desktop.
Save simonpang/5301093 to your computer and use it in GitHub Desktop.
Dreaming of promise event handling v3
- (id)init
{
if (self = [super initNibName:nil bundle:nil]) {
[[[[self whenViewDidLoad] then:^(id result, NSError *error) {
return [self.loginButton whenTouchDown];
}] then:^(id result, NSError *error) {
return [client login:self.loginField.text password:self.passwordField.text];
}] then:^(id result, NSError *error) {
[client saveAccessToken:[result token]];
[self presentModalViewController:[[RegisterViewController alloc] init]];
return nil;
} fail:^(id result, NSError *error) {
[UIAlertView presentError:error];
}];
}
return self;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment