When I close my app I fire off code in applicationDidEnterBackground that downloads some data from a server. In certain situations this can take up to a minute. If the user re-opens the app during that time it will sit on the splash screen until the downloading completes. Is there a way to cancel the downloading when the application is re-opened?
I tried running the download code in the background with performSelectorInBackground within applicationDidEnterBackground but it wouldn’t start running until the app was re-opened.
You’re not allowed to run expensive tasks for long after the application has gone into the background, but what you’re looking for is this:
http://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/UIApplication/beginBackgroundTaskWithExpirationHandler: