0
votes

We save the id of an object to an different class. We have a table view that leads to another table view when the cell is clicked on. The data for the second table view is populated in the initWithCoder method, but it is not displayed in the second table view. We know that the array is not being populated before the view appears. Is there any way we could wait for the array to be populated properly before we display the table view?

Thank you all.

1
Call [tableview reloadData] method after your array get value. - CRDave
Is another table view the view of another view controller? Why not populate array before display the table view? Also, you can always [tableView reloadData] after the data source is populated. - wcd
I am American. I was up til 4am trying to solve this. You solved this for me in 2 minutes. Thank you kind sir. - Dylan Vander Berg

1 Answers

0
votes

Firstly, showing a blank table view isn't a very good user experience; so I'd leave that analysis to you. A decent solution would be to fetch some values (if not all) and pass them to the next view controller.

Nonetheless, in the next table view controller's viewDidLoad, you can add the particular array as an observer. See this: http://nshipster.com/key-value-observing/.

In the observeValueForKeyPath:ofObject:change:context: API, you can reload table view using:

`[self.tableView reloadData]`