Skip to content

Instantly share code, notes, and snippets.

@greenisus
Created September 30, 2011 18:19
Show Gist options
  • Save greenisus/1254563 to your computer and use it in GitHub Desktop.
Save greenisus/1254563 to your computer and use it in GitHub Desktop.
saving an account
- (IBAction)loginButtonPressed:(id)sender {
// this is obviously temporary until we decide on UI for this :)
self.navigationItem.title = @"Authenticating...";
RSAccount *account = [RSAccount blank];
account.provider = self.provider;
account.username = self.usernameTextField.text;
account.api_key = self.apiKeyTextField.text;
[account authenticate:^(CKResult *result) {
if ([result isSuccess]) {
dispatch_async(dispatch_get_main_queue(), ^{
[account save];
[self dismissModalViewControllerAnimated:YES];
});
} else {
[self alert:@"There was a problem logging in. Please check your username and API key."];
}
} errorBlock:^(CKResult *result) {
[self alert:@"login failed"];
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment