title: How to hide buttons, labels, etc for entire time iOS app is running, then show them again at start?
body: <p>I'm coding an iOS app in Objective C. I want the terms and conditions to appear when a user opens the app. I'm going to have a "don't show these again" button, which is all figured out using NSUserDefaults. What I can't figure out is how to make the terms and conditions disappear if the user hits "agree" (termsPressed) but NOT "don't show these again" (neverAgainPressed). I can hide them using button.hidden, but then as soon as the user returns to the main screen of the app the terms and conditions appear again, overlaying the main screen just as they did when the app first launched.</p>
  
  <p>I've tried setting an NSUserDefault when "agree" is pressed, then resetting it when -applicationWillTerminate is called, but it appears that applicationWillTerminate is not called reliably when the app closes if it's closed from the background, and hence the user would never see the terms again even if they hadn't hit "don't show these again". Here's my code:</p>
  
  <pre><code>- (void)viewDidLoad {
      // Hide all the terms and conditions elements if either "neverAgain" or "termsPressed" is true
      NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
      BOOL neverAgain = [defaults boolForKey:@"neverAgain"];
      if (neverAgain == TRUE){
          _terms.hidden=YES;
          _hideTerms.hidden=YES;
          _background.hidden=YES;
          _dontShow.hidden=YES;
      }
      BOOL termsPressed = [defaults boolForKey:@"termsPressed"];
      if (termsPressed == TRUE){
          _terms.hidden=YES;
          _hideTerms.hidden=YES;
          _background.hidden=YES;
          _dontShow.hidden=YES;
      }
  
      NSLog(@"View loaded. termsPressed = %i", termsPressed);
      NSLog(@"View loaded. neverAgain = %i", neverAgain);
  
      [super viewDidLoad];
  }
  
  - (IBAction)neverAgainPressed:(id)sender {
      BOOL neverAgain = TRUE;
      NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
      [defaults setBool:neverAgain forKey:@"neverAgain"];
      [defaults synchronize];
  
      NSLog(@"Don't show terms again pressed, neverAgain set to TRUE");
  }
  
  - (IBAction)termsPressed:(id)sender {
      _terms.hidden = YES;
      _hideTerms.hidden = YES;
      _background.hidden = YES;
      _dontShow.hidden = YES;
      BOOL termsPressed = TRUE;
      NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
      [defaults setBool:termsPressed forKey:@"termsPressed"];
      [defaults synchronize];
  
      NSLog(@"Terms accepted, termsPressed set to TRUE");
  }
  
   - (void)applicationWillTerminate:(UIApplication *)application {
      BOOL termsPressed = FALSE;
      NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
      [defaults setBool:termsPressed forKey:@"termsPressed"];
      [defaults synchronize];
  
      NSLog(@"Application entering background, termsPressed reset to FALSE");
  }
  @end
  </code></pre>
  
  <p>If there was a method that was called every time an app quit, or a version of .hidden that lasted the whole time an app was running, I'd be all set. Let me know if you guys have any ideas.</p>