Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 17th, 2012  |  syntax: None  |  size: 0.86 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to upload 10 images to server from iPhone app?
  2. - (void)applicationDidEnterBackground:(UIApplication *)application
  3. {
  4.     // self.backgroundTask is a property on the app delegate.
  5.     if (self.backgroundTask != UIBackgroundTaskInvalid) // A background task is still in process. Bail early.
  6.         return;
  7.  
  8.     __weak AppDelegate *weakSelf = self; // Create a weak reference to self to avoid retain cycles
  9.     self.backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
  10.         [application endBackgroundTask:weakSelf.backgroundTask];        
  11.         weakSelf.backroundTask = UIBackgroundTaskInvalid
  12.     }];
  13.  
  14.     dispatch_async((DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  15.  
  16.         // Kick off task to upload photos here.
  17.  
  18.         [application endBackgroundTask:weakSelf.backgroundTask];
  19.         weakSelf.backgroundTask = UIBackgroundTaskInvalid;
  20.     });
  21. }