My View Controller gets deallocated when the app goes to the background <p>My View Controller class gets deallocated when the app goes to the background. I'm using ARC.</p> <p>I have a UIViewController that subscribes to a notifications when the app becomes active and executes a method. But once the app is about 30 secs in the background and then resumes, the app crashes with "message sent to deallocated instance". </p> <p>Enabling Zombie objects shows that the View Controller itself is the Zombie.</p> <p>Thank you!</p> <p><b>Instantiation of my view controller (in AppDelegate):</b></p> <pre><code>UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; MyViewController *myViewController = [storyBoard instantiateViewControllerWithIdentifier:@"MyViewController"]; </code></pre> <p><b>The foreground notification in AppDelegate:</b></p> <pre><code>- (void)applicationDidBecomeActive:(UIApplication *)application { [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationForegrounded object:self]; } </code></pre> <p><b>The foreground notification in the view controller:</b></p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resumeForeground) name:kNotificationForegrounded object:nil]; } </code></pre> <p><b>I tried creating a strong reference in the AppDelegate, but the view controller still gets deallocated:</b></p> <pre><code>@property (strong, nonatomic) MyViewController *myViewController; </code></pre> <p><b>I tried adding the view controller to an array and have a strong reference to the array in the AppDelegae, but still I get the same results:</b></p> <pre><code>@property (strong, nonatomic) NSMutableArray *viewControllers; //... UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; MyViewController *myViewController = [storyBoard instantiateViewControllerWithIdentifier:@"MyViewController"]; self.viewControllers = [[NSMutableArray alloc] init]; [self.viewControllers addObject:myViewController]; </code></pre>