Search code examples
iosxcodebackgroundmultitaskingforeground

Xcode re-opening an app


What method is called if I start my app, press the home button and then start the app again/switch to it by doublepressing the home button and selecting it? It is not any of the following as they do not print anything when I re-enter the app:

- (void)applicationWillEnterForeground:(UIApplication *)application {
    NSLog(@"Hi");
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
    NSLog(@"Hi");
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
    NSLog(@"Hi");
}

No other methods on this site look like they are called when I change to the app, except for trying to add this piece of code but that didn't help;

- (BOOL)application:(UIApplication *)application shouldRestoreApplicationState:(NSCoder *)coder {
    return false;
}

It feels like an extremely easy task but I've been testing all possible methods for 3 hours now. What method is called when I re-enter my application after opening it?

Edit: This has been resolved now, if anyone else is having problems of the same sort this image is super helpful. I found it after resolving my issue: http://www.cocoanetics.com/files/Bildschirmfoto-2012-03-05-um-5.26.29-PM.png


Solution

  • Firstly,

    - (void)applicationWillEnterForeground:(UIApplication *)application
    

    method will be called, and after that

    - (void)applicationDidBecomeActive:(UIApplication *)application
    

    method will be called after you open the application from the background thread.