Reputation: 4353
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????
Upvotes: 2
Views: 3437
Reputation: 6830
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.
Upvotes: 2
Reputation: 75058
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.
Upvotes: 0
Reputation: 40507
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.
Upvotes: 7