views:

2763

answers:

4

I have a table view controller that makes an http request, which returns xml. I parse the xml and display it in a UITableView. The first time the http request is called everything works as expected. The second time I call the http request: I receive the xml as expected, but the table does not update. I am calling the reloadData method of the TableView every 2 seconds, so that is not the problem any ideas????

+7  A: 

Set a breakpoint somewhere after you've updated the XML and check to see if the data you're giving the table view is what you're expecting. If not, go through the call stack to see where you're missing something. Also, setting a timer to reload the table view is really a bad practice. Just reload it when you need to, after your data changes.

Marc Charbonneau
A: 

Pretty much the same as Marc's response, but a slightly different action - set a breakpoint in cellForIndexPath where you load data into the cells and see (again as Marc mentioned) if your new data is there.

If the table is not reloading, then your data is not making it to where the table can see new stuff.

Kendall Helmstetter Gelner
+2  A: 

hey are you using threads? if yes then you need to ensure you are reloading the tableview data on the main thread - otherwise tableview does not refresh until you scroll

also reloading the tableview every 2 seconds is the worst way to code. only reload the tableview data when it is actually required

if you are not using threads, make sure you do use them so that your main thread and ui is never blocked when you fire your http requests because http requests take a while to complete.

Raj
i figured out the problem - and I am no longer reloading every 2 seconds :)
zPesk
I had the "using threads" problem. Thanks, your post helped me out.
nazgul42
A: 

I'm using a table view controller inside a tabbarcontroller. Both the tabs have tableviews and whenever I reload the data on the first tab, it reloads without any prob. But, when I want to reload on the second tab, table view reference is coming to be nil (Memory reference as 0x0). Any idea whats gng wrong?

MM
You should ask this as a separate question, not as an answer on this question.
Peter Hosey