Skip to content

Instantly share code, notes, and snippets.

@whakkee
Created November 15, 2012 18:19
Show Gist options
  • Save whakkee/4080255 to your computer and use it in GitHub Desktop.
Save whakkee/4080255 to your computer and use it in GitHub Desktop.
retrieveTweets test
- (void)retrieveTweets
{
NSMutableArray *tweets = [NSMutableArray array];
NSLog(@"thread: %@", [NSThread currentThread]);
NSLog(@"thread: %@", [NSThread mainThread]);
NSLog(@"queue: %@", dispatch_get_current_queue());
self.accountStore = [[ACAccountStore alloc] init];
ACAccountType *twitterAccountType = [self.accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[self.accountStore requestAccessToAccountsWithType:twitterAccountType
options:nil
completion:^(BOOL granted, NSError *e) {
if (granted) {
NSArray *accounts = [self.accountStore
accountsWithAccountType:twitterAccountType];
for (ACAccount *account in accounts) {
[tweets addObject:account.accountDescription];
}
dispatch_async(dispatch_get_main_queue(), ^{
[self.delegate completedWithTweets:tweets];
});
} else {
// Fail gracefully...
NSLog(@"bloop");
}
}];
}
- (void)completedWithTweets:(NSArray *)tweets
{
// dispatch_async(dispatch_get_main_queue(), ^{
// _strings = tweets;
// [self.tableView reloadData];
// });
_strings = tweets;
[self.tableView reloadData];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment