0

I have an app with the following hierrachy:

- Tab bar controller:
    - Table view controller -> Some buttons
    - Table view controller -> Some buttons

When pressing the buttons, the user may have to wait between 1-10 seconds (depending on internet connection). Until the task is completed, the user may exit the app, and when they return they should be able to see the downloaded content.

I realise that I have to implement applicationDidEnterBackground() . I've read the guide, however what I don't understand is that since the data is in another view controller, how do I pass it to the app delegate? The app delegate does not have all the data that it needs to complete the computation. Furthermore, if I'm about halfway through, how do I pass it to the app delegate (without losing the work I've finished)?

Enrico Susatyo
  • 19,372
  • 18
  • 95
  • 156

1 Answers1

2

Register for UIApplicationDidEnterBackgroundNotification and start the task in the VC?

tc.
  • 33,468
  • 5
  • 78
  • 96
  • A briefer version of roughly what I was posting. There's no need to pass anything to the app delegate; check out the notifications documented in http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html (scroll down to the 'Notifications' section, very near the bottom), register your controller to listen for the appropriate ones for as long as you need. – Tommy Jun 28 '11 at 00:19
  • Sorry for my lack of knowledge regarding notifications. So pretty much before I do my task, I write [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(theBigTask) name:UIApplicationDidEnterBackgroundNotification object:nil]; is that what you mean? – Enrico Susatyo Jun 28 '11 at 00:30