
Untitled
By: a guest on
May 17th, 2012 | syntax:
None | size: 0.86 KB | hits: 10 | expires: Never
How to upload 10 images to server from iPhone app?
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// self.backgroundTask is a property on the app delegate.
if (self.backgroundTask != UIBackgroundTaskInvalid) // A background task is still in process. Bail early.
return;
__weak AppDelegate *weakSelf = self; // Create a weak reference to self to avoid retain cycles
self.backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
[application endBackgroundTask:weakSelf.backgroundTask];
weakSelf.backroundTask = UIBackgroundTaskInvalid
}];
dispatch_async((DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Kick off task to upload photos here.
[application endBackgroundTask:weakSelf.backgroundTask];
weakSelf.backgroundTask = UIBackgroundTaskInvalid;
});
}