title: When UIButton is pressed and IBAction is called show UIAlertView with activity indicator in it until done
body: <p>I have a very simple yet annoying question. I have two view controllers, in the first one i have a button that has to go to a server and do some work, i want to show an alert view containing a spinning indicator, that will show up as soon as the button is pressed and dismissed when the second view controller loads. 
  <img src="https://i.stack.imgur.com/IbG3b.png" alt="enter image description here"></p>
  
  <p><br/>I tried this way : </p>
  
  <pre><code>    - (IBAction)logMeInFunction:(id)sender {
  
      UIAlertView  *waitAlert = [[UIAlertView alloc] initWithTitle:@"Please Wait...." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
      [waitAlert show];
  
    /* Do Some Api testing and stuff */
      [waitAlert dismissWithClickedButtonIndex:0 animated:YES];
      [self performSegueWithIdentifier: @"logMe" sender: self];
  }
  </code></pre>
  
  <p>Using this way, the alert show's up and dismisses instantly in the second view controller, not show's up in the first to inform the user that some work is being done and disappears in the second. 
  Any ideas?</p>