2

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?

efpies
  • 3,625
  • 6
  • 34
  • 45

2 Answers2

4

Don't reload table on not main thread

NeverBe
  • 5,213
  • 2
  • 25
  • 39
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