multitasking - iOS 4.0 Task Completion in Background -


I am trying to download an image in the background when using iOS 4.0 I App suspended. What I am when I applicationDidEnterBackground to get the call representatives, I set up an asynchronous NSURLConnection to start and as representatives for the connection application representative. But none of NSURLConnection representatives is calling back. I have captured the network call using Wearhark and I can see that my request was successful and he also got the answer. . (UIApplication *) application {NSLog (@ "entered in the application background state (zero) applicationDidEnterBackground - but as representatives to enforce any of the ways I

  anything to do with the data I am unable to do. "); // UIBackgroundTaskIdentifier bgTask example variable NSAssert (self-> bgTask == UIBackgroundTaskInvalid, zero); bgTask = [application beginBackgroundTaskWithExpirationHandler: ^ {dispatch_async (dispatch_get_main_queue (), ^ {[application endBackgroundTask: Self & gt; bgTask]; self & gt; bgTask = UIBackgroundTaskInvalid;}); }]; NSURLRequest * request = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString: @ "http://animal.discovery.com/mammals/leopard/pictures/leopard-picture.jpg"] cachePolicy: NSURLRequestReloadIgnoringLocalCacheData timeoutInterval: 15]; Self.connection = [[[NSURLConnection alloc] initWithRequest: Request Rep: Auto Start-Up: No] Autoresphere]; [Self. Connection Schedule Inner Loop: [NSRunLoop currentRunLoop] forMode: NSRunLoopCommonModes]; [Self. Connection started]; [Request release]; NSLog (@ "Download Request Sent ...."); Preshk_asink (Preshk_at_man_kyuu) {while ([application background Smaymudran]> 1.0) {// do something ..} [app Andbakgr Task: Self- & gt; Bgtsc]; Self-> Bzitask = UIBackgroundTaskInvalid; NSLog (@ "Ending Background Work ...."); }); }  

When the application goes into the background what should I do to complete a download in the background asynchronously? "Text" itemprop = "text">

I think that you are ending the background work before it actually ends.

When the download ends (both successes and failures), and do not just call [after itself] in NSURLConnectionDelegate method ;: you [; BgTask must keep the call to self & gt application endBackgroundTask]. Connection started]


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -