views:

23

answers:

1

Hey all,

I have a UITableView which shows some information. The informations are from a XMLFile. The Xmlfile is pretty big, about 500 entries.

I don't want that the user has to wait until the parsing has finished, i want to add cell by cell to the TableView.

Here's my code:

-(void) onFinishedPartDownload:(id)item
{
    if(odvTableViewDelegateController.odvs == nil)
        odvTableViewDelegateController.odvs = [NSMutableArray new];

    if([odvTableViewDelegateController.odvs count]==0)
    {
        genericDelegate.tableView.delegate = odvTableViewDelegateController;
        genericDelegate.tableView.dataSource = odvTableViewDelegateController;
    }

    [odvTableViewDelegateController.odvs addObject:item];

    [genericDelegate.tableView reloadData];
}

This method is called everytime an item has parsed, but it reloads the tableView all at once at the end. I don't have my expected liveUpdate which i'm searching for.

The intervall the method is called is about 0.001 to 0.0025 seconds.

Any ideas to fix that?

Sebastian

+2  A: 

It would seem the XML parsing is taking place on the main thread. It's likely the parser has complete control of the thread and will not relinquish it until parsing is complete. It is at that time the UI will have a chance for the UITableView to update, which is why you're seeing everything happen at the very end. My recommendation (if you don't have things implemented this way already) would be to execute the XML parsing on a thread, leaving the main thread for UI updates and other user interaction.

fbrereto
Yes, the parsing and the adding are in the same thread (main-thread). I will try to seperate the parsing to an extra thread on monday.
antihero
Okay, i couldn't resist and tried you tipp. It works perfect =) thank you very much!
antihero