I'm trying to get a list of twitter accounts to load up a UITableViewController that contains the data. I use this function:
- (void)viewDidLoad {
[accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
...
[[self tableView] insertRowsAtIndexPaths ...];
[[self tableView] reloadData];
NSLog("This message appears immediately");
...
}];
NSLog("This message appears immediately");
}
For some reason, the interface seems to "hang" for 5 seconds before the table actually gets updated / redrawn (note that I AM calling reloadData!). All my log messages get printed right away, so I'm not sure what's causing the interface to freeze up.
All,
So, I figured it out (sort of). I guess it has something to do with the threads, I wasn't supposed to do any UI stuff in that thread.
To fix it, I surrounded the table stuff with some dispatching code:
[account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
{ dispatch_async(dispatch_get_main_queue(), ^{
...
});}];
Still need to understand what's going on here, but hopefully this will help if someone runs into the same problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With