0
-(void) closeUpShopBeforeBackgrounding {

    // this listen to the UIApplicationDidEnterBackgroundNotification  

    [self beginBackgroundUpdateTask];
        // do some closing stuff
    [self endBackgroundUpdateTask]; }

- (void) beginBackgroundUpdateTask {
    self.backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
        [self endBackgroundUpdateTask];
    }]; }

- (void) endBackgroundUpdateTask {
    [[UIApplication sharedApplication] endBackgroundTask: self.backgroundTask];
    self.backgroundTask = UIBackgroundTaskInvalid; }

This code is working fine for me, but when I foreground the app again, its dead in the water. Its as if the viewDidLoads are not firing, and nothing is happening.

Is there anything I need to do when the app foregrounds to kick it back into life?

Dave
  • 44,275
  • 12
  • 65
  • 105
Jonathan
  • 111
  • 1
  • 4
  • 1
    The `viewDidLoad`s should only be called when the view is *first* loaded. Maybe you're looking for the events in this answer: http://stackoverflow.com/a/3857559/1180785 ? – Dave Jun 03 '13 at 20:14
  • Thanks Dave. I actually found - and use - that solution already. I was just wondering why the processes/threads were all brought to a halt as soon as I started using the endBackgroundTask when UIApplicationDidEnterBackgroundNotification is called. – Jonathan Jun 04 '13 at 19:44
  • I figured it out by re-running init() on my business logic class when UIApplicationWillEnterForegroundNotification is called. I am not confident I understand what's going on behind the scenes, but the app appears to roar back into life when I start all the timers referenced in the init method of my business logic class. – Jonathan Jun 04 '13 at 19:46

0 Answers0