title: iOS 7 - Difference between viewDidLoad and viewDidAppear
body: <p>Sorry but this may not be a programming question per se but more of an inquiry over the nature of iOS lifecycle functions. </p>
  
  <p>I have an application where I have a function that creates four arrays and populates them via database queries. At first, I called the function from the <code>viewDidLoad</code> function, however, whenever the View is loaded, it takes time (around 3-4 seconds) before the view actually appears. So what I did was I created an <code>activityViewIndicator</code> and my <code>viewDidLoad</code> function looks something like:</p>
  
  <pre><code>- (void)viewDidLoad:(BOOL)animated{
      [super viewDidLoad];
  
      NSLog(@"viewDidLoad Entered");
      [self.activityIndicatorView startAnimating];
  
      partInput.delegate = self;
      brandInput.delegate = self;
      barcodeInput.delegate = self;
      itemNameInput.delegate = self;
  
      //initializeArrays is the function that initializes the arrays
      [self initializeArrays];
  
      [self.activityIndicatorView stopAnimating];
  
  }
  </code></pre>
  
  <p>However this doesn't work since the <code>viewDidLoad</code> function is triggered when the application is still in the previous View. The View only comes into display after <code>viewDidLoad</code> is already done. So what I did instead was move the array initialization to my <code>viewDidAppear</code> function which looks like: </p>
  
  <pre><code>- (void)viewDidAppear:(BOOL)animated{
      NSLog(@"viewDidAppear loaded successfully");
      [self.activityIndicatorView startAnimating];
  
      partInput.delegate = self;
      brandInput.delegate = self;
      barcodeInput.delegate = self;
      itemNameInput.delegate = self;
  
      [self initializeArrays];
  
      [self.activityIndicatorView stopAnimating];
  
  }
  </code></pre>
  
  <p>However, when I deployed this, there was no delay whatsoever, making the activityIndicatorView useless. </p>
  
  <p>My question is, why does it seem to me that there's a "performance difference" between <code>viewDidLoad</code> and <code>viewDidAppear</code>? </p>