views:

67

answers:

3

Hi.

I have a bunch of connection related methods that I need to execute before the table is actually being populated (before any of the delegate methods for a UITableView are called). The connection methods will add objects in a NSMutableArray that will later be used to populate the table view.

Is there a way to tell the iPhone to wait until all the connection methods are done, before it starts with the delegate methods relating to a UITableView in a UITableViewController?

Cheers!

+2  A: 

I had a similar issue. What you can try is to not set the table view's datasource and delegate properties until after your connection methods are done. In IB, don't hook up the datasource and delegate connectors of the table view (leave them unconnected). Then in code, when your connection methods are done, set the datasource and delegate to self and call reloadData on the table view.

Padawan
+5  A: 

Cant you just do a [table reloadData] when you are finished with all the connections? All the delegate methods really should be safe to use if the data source is still empty.

willcodejavaforfood
+1  A: 

A common pattern used when setting up a table view, is to create the view controller, set data within the view controller, and then present the view controller (modally or otherwise). The table view will not start requesting data until you try to display it, creating a view controller does not create the view until the view is requested.

Kendall Helmstetter Gelner