kaiserphellos
kaiserphellos

Reputation: 253

Updating Table View As Items Are Downloaded

I have a series of table views. When an item in the first table view is pressed, it calls a webservice, parses a bit of xml, then generates the next table view based on the data. I am wondering how it would be possible to update the table view after each item in the xml document is parsed. I tried passing the table view object to the xml parsing delegate and calling reloadData on the table view whenever I am finished parsing an individual item, but it still waits until the entire document is finished parsing to display the cells.

Upvotes: 1

Views: 115

Answers (1)

Rob
Rob

Reputation: 437897

Others have pointed out the advantages to asynchronous parsing of your XML and updating your UI, but you should also note that your choice of XML parser might be relevant. If you use NSXMLParser, for example, it tends to download the entire XML feed from the remote server before parsing starts (so there is little benefit in trying to improve the UI by updating as parsing takes place because the main delay, downloading from the remote server, is cooked in before parsing commences ... the time spent parsing is often negligible in comparison to the time spent downloading the remote XML feed).

If you look at Apple's XMLPerformance sample, they actually compare and contrast NSXMLParser and LibXML2. The latter will parse as the download progresses, whereas the former won't start until the download is done. (As an aside, this impacts not only how quickly user interface updates take place, but also the memory footprint of the parsing process.)

I'd also suggest that you look at Ray Wenderlich's article, How To Choose The Best XML Parser for Your iPhone Project.

Upvotes: 1

Related Questions