I update the UITableView
on timer. I change data in array, then call -[UITableView reloadData]
. But nothing is changed until I scroll the table or switch tabs in the tab bar. What's happening? How can I avoid this?
Asked
Active
Viewed 1,644 times
2

efpies
- 3,625
- 6
- 34
- 45
-
1do you call reloadData on main thead? – NeverBe Oct 11 '12 at 19:38
2 Answers
4
The problem was in that:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
self.newList = [self loadData];
[self.delegate list:self didUpdate:self.newList];
});
Delegate call was on the background thread. If you want to update UI you should do in on the main thread.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
self.newList = [self loadData];
dispatch_async(dispatch_get_main_queue(), ^{
[self.delegate list:self didUpdate:self.newList];
});
});

efpies
- 3,625
- 6
- 34
- 45