GeneralMike
GeneralMike

Reputation: 3001

What determines load order for multiple UITableViews?

I have a UIViewController with 3 different UITableViews on it. Two of the tables depend on what is in the third. When the app starts, it's loading the two dependent tables before it loads the independent one, so I am not getting the behavior expected. If I continue to a different screen then come back, I get the expected behavior, so I know my code that dictates the behavior is correct. What I think I need to do is specify which table is processed by cellForRowAtIndexPath first. Can that be done in viewDidLoad, or anywhere else for that matter? How does it determine which table to process first?

Upvotes: 0

Views: 31

Answers (1)

deanWombourne
deanWombourne

Reputation: 38475

On loading, you don't know the order. You could guess but it might be different in different iOS versions so it's not worth the effort.

To fix it, in your viewDidLoad method, just call reloadData for the table views in the order you need :)

However, the fact that you have a load order for the table views means that you proably haven't separated out your data and your UI enough :) You're table views shouldn't depend on each other, they should depend on variables that are stored in your view controller so they can be reloaded in any order at any point (in an ideal world :)

Upvotes: 2

Related Questions