-1

Like the question said.

I tried NSOperationQueues but I am confused as to what to execute in the operation block. I tried the function reloadData to load in the operation queue but all the UITableViews appear at once.

I am using custom cells on the said UITableViews.

TIA

Anton Unt
  • 1,835
  • 1
  • 21
  • 47
  • Did you try using GCD for this? You can use serial dispatch queues for this purpose. – Puneet Sharma Jul 25 '13 at 12:14
  • Unless you have 50 table views all on screen at the same time, you are doing something wrong. You should probably have 50 datasource/cell delegates and one table view. Save the scroll position and simply swap out the data to transition between the datasets. – Mike Weller Jul 25 '13 at 12:22

1 Answers1

0

If your data loading is done on background threads you need to ensure that you return to the main thread before triggering any change to UI. So, when you call reloadData, make sure it runs on the main thread:

[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
Wain
  • 118,658
  • 15
  • 128
  • 151
  • Thank you, but the table views are loading fine. Just that they are taking an awful lot of time and they all appear at once on the page. I have 50 Tableviws on that view and I want each of them to load the data one by one. I tried adding "ReloadData" method of TableView to an operation queue with MaxConcurrentOperations set to 1 and runs in the background. Still no luck. Will anything change if I add this line? Because TableView's delegate methods always get called on the main thread. – Anton Unt Jul 25 '13 at 12:25
  • Your queue setup sounds ok, but each operation should reload the table view (on the main thread) before the next one starts. – Wain Jul 25 '13 at 12:31