title: AlertViewController - whose view is not in the window hierarchy Issue
body: <p>In the following code, I am trying to call the method handleEvent only once a particular event takes place. For this, I post a notification where the event occurs (not shown in code below) , so that the notification is observed by observer and handleEvent ( as in code below). </p>
  
  <p>I want a alert viewController to pop-up and take the text entry so that I can receive it. 
  But I am getting following error : </p>
  
  <pre><code>Warning: Attempt to present &lt;UIAlertController: 0x7f9d1347ed90&gt; on &lt;MSMDemoFirstViewController: 0x7f9d1347e920&gt; whose view is not in the window hierarchy!
  </code></pre>
  
  <p>I am unable to understand although I am using singleton, I am unable to get the alertViewController properly. Any help can be of great use.</p>
  
  <pre><code>   #import "MSMDemoFirstViewController.h"
  #import "CAMDOReporter.h"
  static MSMDemoFirstViewController * instance = nil;
  @interface MSMDemoFirstViewController ()
  
  @end
  
  @implementation MSMDemoFirstViewController
  
  + (MSMDemoFirstViewController *)sharedInstance {
      // Singleton implementation
      static dispatch_once_t onceToken;
      dispatch_once(&amp;onceToken, ^{
          if (instance == nil) {
              instance = [[MSMDemoFirstViewController alloc] init];
          }
      });
      return instance;
  }
  
  +(void)load{
  [[NSNotificationCenter defaultCenter] addObserver:[MSMDemoFirstViewController sharedInstance] selector:@selector(handleEvent:) name:EVENT_OCCURRED object:nil];
  }
  
  
  +(void) initialize{
  
  }
  - (void) viewDidAppear:(BOOL)animated {
      [super viewDidAppear:animated];
      //[[CAMDOReporter sharedInstance] startApplicationTransaction:@"DemoEventApplicationTransaction"];
     // [self showAlert];
  }
  
  -(void)showAlert{
      NSLog(@"2ew");
      NSString *title = NSLocalizedString(@"A Short Title Is Best", nil);
      NSString *message = NSLocalizedString(@"A message should be a short, complete sentence.", nil);
      NSString *cancelButtonTitle = NSLocalizedString(@"Cancel", nil);
      NSString *otherButtonTitle = NSLocalizedString(@"OK", nil);
  
      UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
  
      [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
          // If you need to customize the text field, you can do so here.
      }];
  
      // Create the action.
      UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
          NSLog(@"The simple alert's cancel action occured.");
      }];
  
      UIAlertAction *otherAction = [UIAlertAction actionWithTitle:otherButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
          NSLog(@"The \"Text Entry\" alert's other action occured.");
      }];
      // Add the action.
      [alertController addAction:cancelAction];
      [alertController addAction:otherAction];
      [self presentViewController:alertController animated:YES completion:nil];
  }
  
  -(void)handleEvent:(NSNotification *)note{
      NSLog(@"Handle Crash Event");
      NSDictionary *crashData  = [note userInfo];
      if(crashData !=nil){
          //Implement any UI Logic to get any response from the user. e.g. AlertView, TextFields.
          //Once the feedback is received convert it into NSString and send the data.
          // Show a text entry alert with two custom buttons.
          [[MSMDemoFirstViewController sharedInstance] showAlert];
          NSString *feedback=[[NSUserDefaults standardUserDefaults] objectForKey:@"crashDetails"];
          [[CAMDOReporter sharedInstance] setCustomerFeedback:feedback];
      }
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  
  @end
  </code></pre>
  
  <p>Now the output I am getting is : </p>
  
  <pre><code>2015-01-21 20:17:45.762 CAMAADemo[18891:1558312] Handle Crash Event
  2015-01-21 20:17:45:762 CAMAADemo[18891:1807] Posting Notification about crash
  2015-01-21 20:17:45.762 CAMAADemo[18891:1558312] 2ew
  2015-01-21 20:17:45.778 CAMAADemo[18891:1558312] Warning: Attempt to present &lt;UIAlertController: 0x7ff5d2273580&gt; on &lt;MSMDemoFirstViewController: 0x7ff5d2204be0&gt; whose view is not in the window hierarchy!
  </code></pre>
  
  <p>This means the call is going to showAlert Method, but then though I am getting same error.</p>
  
  <p>Even the following code does not help.</p>
  
  <pre><code>-(void)viewDidLoad{
      [super viewDidLoad];
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleCrashEvent:) name:CAMAA_CRASH_OCCURRED object:nil];
  }
  -(void)showAlert{
      NSLog(@"2ew");
      NSString *title = NSLocalizedString(@"A Short Title Is Best", nil);
      NSString *message = NSLocalizedString(@"A message should be a short, complete sentence.", nil);
      NSString *cancelButtonTitle = NSLocalizedString(@"Cancel", nil);
      NSString *otherButtonTitle = NSLocalizedString(@"OK", nil);
  
      UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
  
      [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
          // If you need to customize the text field, you can do so here.
      }];
  
      // Create the action.
      UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
          NSLog(@"The simple alert's cancel action occured.");
      }];
  
      UIAlertAction *otherAction = [UIAlertAction actionWithTitle:otherButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
          NSLog(@"The \"Text Entry\" alert's other action occured.");
      }];
      // Add the action.
      [alertController addAction:cancelAction];
      [alertController addAction:otherAction];
      [self presentViewController:alertController animated:YES completion:nil];
  }
  
  -(void)handleCrashEvent:(NSNotification *)note{
      NSLog(@"Handle Crash Event");
      NSDictionary *crashData  = [note userInfo];
      if(crashData !=nil){
          //Implement any UI Logic to get any response from the user. e.g. AlertView, TextFields.
          //Once the feedback is received convert it into NSString and send the data.
          // Show a text entry alert with two custom buttons.
          [self showAlert];
          NSString *feedback=[[NSUserDefaults standardUserDefaults] objectForKey:@"crashDetails"];
          [[CAMDOReporter sharedInstance] setCustomerFeedback:feedback];
      }
  }
  </code></pre>