Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Mac2011

macrumors newbie
Original poster
Jan 11, 2011
11
0
So my question is: How can I wait to load the tableview until the data is loaded.
Unfortunately I can't use connectionDidFinishLoading in a while loop because it's a void message.
Any suggestions?
 
So my question is: How can I wait to load the tableview until the data is loaded.
Unfortunately I can't use connectionDidFinishLoading in a while loop because it's a void message.
Any suggestions?

On other platforms I've used, a writer can lock the table. It will not write until it gets the lock. The reader if it issues a read will block until the lock is removed by the writer. On many systems this is effisent as no polling is involved the system only checks when lock states change
 
Thx. I'll try it. Maybe there is a way that I lock the "main" thread until a second thread is done or a queue of things it should do.
 
Sounds like you're going about it the wrong way. You should let the tableView go ahead and load empty when the view is loaded. Once the data has been downloaded and stored in your datasource you should set up a delegate method in your table view controller to update the table view to display your new data.

A great way to update the table view is:

Code:
[tableView beginUpdates];

// insert some rows, do whatever updates

[tableView endUpdates];

That will animate all of the updates in the begin/end block in a very nice way. It's pretty neat. For more information check out the documentation on UITableView.

http://developer.apple.com/library/...ce/UITableView_Class/Reference/Reference.html
 
Wirelessly posted (Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F5153d Safari/6533.18.5)

Yep. Now I got. Very simple. I created a NSoperationqueue in viewdidload and a delegate. after the connection did finish launching method, a method gets called to set the data for the table view and than reload its data. I think that's the best way to go and the UI doesn't get stuck either.
 
If you like you can add a row to the table that says Loading... or something like that and then remove it when the data arrive.

LazyTableImages does something like this.
 
There is a sample named LazyTableImages in xcode help document.
I think it's just what you wanted.
:)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.