Skip to content

Instantly share code, notes, and snippets.

@simonpang
Created April 2, 2013 14:54
Show Gist options
  • Save simonpang/5292844 to your computer and use it in GitHub Desktop.
Save simonpang/5292844 to your computer and use it in GitHub Desktop.
Dreaming of promise base event handling v2
- (id)init
{
if (self = [super initNibName:nil bundle:nil]) {
[[self whenViewDidLoad] then:^(id result, NSError *error) {
[[self.loginButton whenTouchDown] then:^(id result, NSError *error) {
[[client login:self.loginField.text password:self.passwordField.text] then:^(id result, NSError *error) {
[client saveAccessToken:[result token]];
[self presentModalViewController:[[RegisterViewController alloc] init]];
} 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