Created
April 3, 2013 13:14
-
-
Save simonpang/5301093 to your computer and use it in GitHub Desktop.
Dreaming of promise event handling v3
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
- (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