Q:

DidEnterBackground - Keep waiting for an ASIHTTP request and parsing result

Maybe you could help me to find the appropriate way to handle this :

I have a NSTimer (started in my AppDelegate) which fires a class to launch a asynchronous server request (I use ASIFormDataRequest)
When HTTP JSON-response is received, I parse it using TouchJSON
Then I loop the NSDictionary obtained to fill a dedicated NSManagedObjectContext
Then I save this context on some user interactions

Sometimes the HTTP request is sent and the user quit the application. I want to get extra time in order to complete tasks 2 to 4 in background.
I read the Apple doc but it is still not clear how to gain extra time for an asynchronous action already started ?
In short, how should i use the beginBackgroundTaskWithExpirationHandler ?
Thanks for your very usefull help.
Kheraud

A:

ASIHTTPRequest supports running requests in the background:
[request setShouldContinueWhenAppEntersBackground:YES];

If you do steps 2-4 inside the delegate notifications and set the above flag then that should do what you want.
You won't be able to interact with the user once your application has entered the background though.

