title: Objective-C: Obscuring Data when in Background not working
body: <p>I've been trying to obscure data when the application enters the background state by hiding it in the task switcher.</p>
  
  <p>here is my <strong>AppDelegate.h</strong> file</p>
  
  <pre><code>@interface AppDelegate : UIResponder
  &lt;
      UIApplicationDelegate,
      MemberServicesManagerDelegate
  &gt;
  {
      UIWindow* window;
      Reachability* reachbility;
  }
  
  @property(nonatomic, strong) UIViewController *mainViewController;
  @end
  </code></pre>
  
  <p>This is my <strong>AppDelegate.m</strong> file</p>
  
  <pre><code>- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
      { window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
  
          window.rootViewController = StartupController.instance.startingViewController;
          if(DEVICE == IPAD){
              self.mainViewController = window.rootViewController.childViewControllers[0];
          }
          [window makeKeyAndVisible];
  }
  - (void)applicationDidEnterBackground:(UIApplication *)application
  {
      //1
      //self.window.hidden = YES;
  
      //2
      //UIViewController *image = [UIViewController new];
      //image.view.backgroundColor = [UIColor blackColor];
      //[window makeKeyAndVisible];
      //[window.rootViewController presentViewController:image animated:NO completion:NULL];
  
      //3
          UIView *colourView = [[UIView alloc]initWithFrame:window.frame];
          colourView.backgroundColor = [UIColor blackColor];
          colourView.tag = 1234;
          colourView.alpha = 0;
          [window addSubview:colourView];
          [window bringSubviewToFront:colourView];
  
          [UIView animateWithDuration:0.5 animations:^{
              colourView.alpha = 1;
          }];
  
  
      NSLog(@"BACK");       
  }
  
  - (void)applicationWillEnterForeground:(UIApplication *)application
  {
      //1
      //self.window.hidden = NO;
  
      //2
      //[window.rootViewController dismissViewControllerAnimated:NO completion:NO];
  
      //3
          UIView *colourView = [window viewWithTag:1234];
          [UIView animateWithDuration:0.5 animations:^{
              colourView.alpha = 0;
          } completion:^(BOOL finished) {
              [colourView removeFromSuperview];
          }];
  
      NSLog(@"ForeGround");
  }
  </code></pre>
  
  <p>I tried these 3 implementations but It won't hide the view when I enter the multitask switcher.</p>
  
  <p>I tried this with both simulator and real device but it still won't work. Can you help me with this?</p>