Skip to content

Instantly share code, notes, and snippets.

@0xjmp
Created February 12, 2013 23:03
Show Gist options
  • Save 0xjmp/4774308 to your computer and use it in GitHub Desktop.
Save 0xjmp/4774308 to your computer and use it in GitHub Desktop.
- (IBAction)login:(UIButton *)sender
{
NSString *userName = self.emailTextField.text;
NSString *password = self.passwordTextField.text;
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = @"Logging In...";
TTLoginController *login = [[TTLoginController alloc] init];
login.onLoginSuccessful = ^(TTUser *user) {
[TTUser loginWithUsername:userName password:password block:^(TTUser *user2, NSError *error) {
if (error) {
[UIAlertView showAlertViewWithTitle:NSLocalizedString(@"Server Error", @"Login Error Title")
message:NSLocalizedString(@"A Server error occurred. Please try again", @"Login Error Message")
cancelButtonTitle:NSLocalizedString(@"OK", @"Login Error OK Button")
otherButtonTitles:nil
handler:nil];
} else {
// Temporary fix to avoid a retain cycle.
TTLoginController *loginAgain = [[TTLoginController alloc] init];
loginAgain.onLoginSuccessful(user2);
}
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment