2

Let say someone is using my app and the change the settings in the settings bundle, when they come back to my app I would like my view to update (via my updating method) according to those settings. I've tried many different things but I just can't get it to work.

What is the best way to implement this kind of behavior for my iPhone app?

Christian Gossain
  • 5,942
  • 12
  • 53
  • 85

2 Answers2

6

in your AppDelegate put these methods:

- (void)applicationWillEnterForeground:(UIApplication *)application {
    /*
     Called as part of  transition from the background to the active state: here you can undo many of the changes made on entering the background.
     */
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */
}

Then you have hooks to do whatever you want.

Cœur
  • 37,241
  • 25
  • 195
  • 267
coneybeare
  • 33,113
  • 21
  • 131
  • 183
4

It's worth noting that you're not limited to the AppDelegate; you can listen for these events from anywhere in your code with an NSNotification. See this answer for more details on how to listen for UIApplicationDidBecomeActiveNotification.

Community
  • 1
  • 1
Reed Olsen
  • 9,099
  • 4
  • 37
  • 47