title: Making some code only run once
body: <p>I have some code that I would like to run only once in my MainViewController. It should run every time the user starts the app, but only after the MainViewController has loaded.</p>
  
  <p>I don't want to run it in <code>-(void)applicationDidFinishLaunching:(UIApplication *)application</code>.</p>
  
  <p>Here's the idea I had:</p>
  
  <p>MainViewController.h</p>
  
  <pre><code>@interface IpadMainViewController : UIViewController &lt;UISplitViewControllerDelegate&gt; {
      BOOL hasRun;
  }
  
  @property (nonatomic, assign) BOOL hasRun;
  </code></pre>
  
  <p>MainViewController.m</p>
  
  <pre><code>@synthesize hasRun;
  
  -(void)viewDidLoad {
      [super viewDidLoad];
      if (hasRun == 0) {
          // Do some stuff
          hasRun = 1;
      }
  }
  </code></pre>
  
  <p>Any ideas?</p>