Andy Bourassa
Andy Bourassa

Reputation: 1838

Initializing UITableView with remote data source

Edit: Originally this question contained a really stupid bug description I was experiencing but I've now figured out it was totally unrelated to what I thought. So I'm just going to turn this into a UITableViews with remote data source best practices.

As a more general question: How does everyone like to handle UITableViews (or UIViews in general) with remote data sources (i.e. loaded via async NSURLConnections, sockets etc.)? What are some best practices for initializing the TableView data source before it has been loaded?

Does anyone want to provide examples or discussion regarding the use of asynchronous NSURLConnections or NSStreams with socket connections?

Upvotes: 0

Views: 547

Answers (2)

Bogatyr
Bogatyr

Reputation: 19323

To the question of handling high latency data sources: the usual practice is to load the data in a background thread so that the UI remains responsive (NSoperation and NSOperationQueue are great for this, I use them frequently for this purpose), and to show a spinning activity indicator for any views whose contents are not ready yet but have been requested.

Only add the data to your model / user interface elements when it is finally available (using NSNotifications are a good way to signal that data is ready). The way to refresh your table view when more model / display data is available is to call [tableView reloadData].

Upvotes: 1

Matthias Bauch
Matthias Bauch

Reputation: 90117

First you should check if the property of your datasource array really retains the object.

I've said "I've done the exact same thing" too often to believe it.

Upvotes: 1

Related Questions