Reputation: 624
So I'm trying to do all my REST calls that download data on the background thread so that the UI stays responsive.
I have a viewcontroller that contains a NSOperationQueue. I create an instance of my importer class that is a subclass of NSOperation. Inside the main() method of my importer, I am setting up a ASIHTTPDataRequest. I create the request, then its time to kick off the request.
Problem: I ran into a problem when starting the request by calling "startAsynchronous" on the request. The delegate call backs never get called. Its like the request starts, downloads its data, but never calls the delegate callback methods.
My solution: Everything seems to work fine (i.e. callbacks, etc) when I start the request synchronously. Is this the correct solution?
Why does the synchronous call work, but not the asynchronous? I'm modeling my importer class after Apples "TopSongs" sample.
Upvotes: 2
Views: 3290
Reputation: 33592
ASIHTTPRequest itself should not block the UI if you run it from the main thread.
If it's parsing the data that's taking a long time, stick that in an operation.
Upvotes: 6
Reputation: 9318
When the method main()
is end executing, NSOperation
seted to finished and released, so you newer receive delegate callbacks because delegate is released.
Upvotes: 1