jireh
jireh

Reputation: 89

How to make an App working in an background?

I am developing an application, in which I am fetching some photos from the XML link using NSXMLParser, so it takes some time to load images into view, while loading if I click on the home button in iPhone (device) and open the application again, the App crashes. I didn't know how to make my app to be able to run also in background state. I googled and found, "App States and Multitasking" but i can't able to make it in my application. Any solutions or links will be appreciated.

Upvotes: 0

Views: 84

Answers (1)

Ben10
Ben10

Reputation: 3259

Try This

UIBackgroundTaskIdentifier backgroundTask = 0;
 UIApplication  *application= [UIApplication sharedApplication];
backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
    [application endBackgroundTask:backgroundTask];
}];

use this code in your application at initial method

- (void)applicationDidEnterBackground:(UIApplication *)application
{
//call your upload method
}

Upvotes: 3

Related Questions