Hello I have a problem with UITableView freeze,
“downloadItem” below gets called when someone clicks on a button on the iPad. Its supposed to download a file and then return.
During the download, while stuck in that function, I want the UI to still be responsive, so I installed a runloop like below.
The actual downloadItem function is WAY more complicated than shown below, but what is shown is the basic idea of it. I know this isn’t the best way, but for other reasons, I can’t change it at this time, especially due to the existing complexity of the actual function.
The problem is that I also have a UITableView on the screen (as well as the button), if the UITableView is clicked or scrolled while in this function, in the runloop, the UITableView sometimes freezes up, and remains frozen even after exiting this function. This doesn’t happen every time for some reason, maybe 40% of the time.
Does anyone know how to fix, is the RunLoop call below done right? Why when I click on the UITableView while in the runloop below, the table sometimes freezes up?
-(IBAction) downloadItem
{
BOOL downloading=TRUE;
callFunctionsToStartdownload(...);
while (downloading) {
downloading=DownloadSomeBytes(...);
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, YES);
}
}
thanks
In general, this seems unnecessary. You want the processing of downloaded bytes to be in a thread (which this does not address), but the actual asynchronous NSURLConnection should do its work in a thread (and then calls back to the thread that started it).