0

Although this question has been answered here:

How to tell when UITableVIew has completed ReloadData?

The 13 answers are so convoluted with issues and alternatives that I am hopelessly confused.

Would someone, who understands this, synthesize a single answer?

EDIT: For others who may be following How to tell when UITableVIew has completed ReloadData?, Nextman's comment below offered a possible solution.

Carl Carlson
  • 500
  • 4
  • 17
  • 1
    reloadData is synchronous; it is finished by the time you reach the next line code. The actual view/layout may not get updated until the next pass through the run loop. What are you trying to achieve? – TheNextman Apr 11 '18 at 01:44
  • My experience as well as the referenced question above seem to indicate that reloadData is not actually completed until the end of the run loop. Any method that attempts to query the tableView after reloadData but before the the next run loop cycle is initiated fails. I have inserted data into the data source, then called reloadData. Now, I want to select the new row (item) which requires: rowForItem, and selectRowIndexes, but rowForItem returns -1. Perhaps I don't understand. It wouldn't be the first time. I appreciate your help. – Carl Carlson Apr 11 '18 at 03:45
  • `UITableView` ≠ `NSOutlineView` but `dispatch_async(dispatch_get_main_queue(), ^{});` should work. How do you add a row? Please add your code to the question. – Willeke Apr 11 '18 at 08:26
  • I'm afraid you will have to show a reproducible example of your issue. I just tried a simple test of an array-backed `NSOutlineView` and I am able to insert a row, call `reloadData`, and then select the row with `rowForItem` and `selectRowIndexes`. It works fine all in the same method call, without need to dispatch. – TheNextman Apr 11 '18 at 15:17
  • https://pastebin.com/Myc2VwfT – TheNextman Apr 11 '18 at 15:19
  • MY SINCERE APPOLOGIES. I sent setNeedsDisplay to the wrong outlet. – Carl Carlson Apr 11 '18 at 17:32

0 Answers0