views:

239

answers:

1

Each time somebody touches a row inside a UITableView, I'm kicking off a series of asynchronous NSURLConnections, that download data and then parse and save that data into Core Data.

The problem is that when I do this, the UI is responsive during the data download, but as soon as the parsing and saving begins, the UI becomes non-responsive.

The NSURLConnection is wrapped inside a class, that implements the NSURLConnection protocol, and when the NSURLConnection is fires didLoadResource, it kicks off a DataAdapter class that handles the parsing and saving. I'm thinking thats the cause of my UI blocking.

Has anyone dealt with this before? What are my options? Put the DataAdapter into an NSOperation?

+1  A: 

By default, Core Data operates on the main thread which is the same thread used by the UI. You need to either create a separate context in another thread or (easier) wait until the down load is finished before moving the information into Core Data. Right now, Core Data is freezing the main thread and the interface while it waits for some data to finish downloading.

See Multithreading with Core Data.

TechZen
Core Data should be waiting till its done downloading data. The DataAdapter doesnt start parsing and saving untill the NSURLConnection delegate method of - (void)connectionDidFinishLoading:(NSURLConnection *)connection gets called.
Bryan