Why does “numberOrRowsInSection” get called mid-way through “viewDidLoad”?

The tableView:numberOfRowsInSection: method is likely called because you configured something on your table view (maybed you've added it to its superview) and it therefor needed to know its metrics. It does not magically trigger by itself out of the blue. Either make sure to prepare your data before you configure the UI elements or call reloadData near the end, but I'd find the former to be "cleaner.

The tableView:numberOfRowsInSection: method is likely called because you configured something on your table view (maybed you've added it to its superview) and it therefor needed to know its metrics. It does not magically trigger by itself out of the blue. Either make sure to prepare your data before you configure the UI elements or call reloadData near the end, but I'd find the former to be "cleaner".

– Greg Mar 19 at 8:51 Yes, setting up and configuring UI elements in viewDidLoad is perfectly fine. And yes, you've understood that correct: inside the viewDidLoad method first set up the non-UI data (as far as they don't rely on data from UI elements), and then set up the UI elements. This way you don't need to call reloadData yourself, it will be called at a time convenient to the table view and thus prevents unnecessary method calls.

– DarkDust Mar 19 at 8:56.

This is perfectly normal.... Call self. TableView reloadData ; at the end of viewdidload.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions