title: MainViewController pushViewController:animated:]: unrecognized selector sent to instance 0x1459e980
body: <p>I'm trying to add a functionality to open a specific view controller on opening the notification on my iOS app. As I am new to iOS, I have a few doubts.</p>
  
  <p>I have written the backend, which sends the promo id as a custom parameter. I am able receive the JSON object on XCode, read the ID as a NSString.</p>
  
  <p>Now, I want to open the PromotionDetailViewController with the promotion id as the parameter.</p>
  
  <p>What I have done up to now is,</p>
  
  <pre><code>    PromotionDetailViewController *pVC = [[PromotionDetailViewController alloc] initWithPromotionID:promo_id[@"promo_id"]];
      [(UINavigationController *)self.window.rootViewController pushViewController:pVC animated:YES];
  
      [(UINavigationController *)[UIApplication sharedApplication].keyWindow.rootViewController popViewControllerAnimated:YES ];
  </code></pre>
  
  <p>I am able to receive and read the promo ID in the AppDelegate.m file.
  When I run the above code, I get the below error.</p>
  
  <blockquote>
    <p>MainViewController pushViewController:animated:]: unrecognized
    selector sent to instance 0x1459e980</p>
  </blockquote>
  
  <p>Any help in the right direction is great! I do php and android, but Obj-C is quite different!</p>
  
  <p><strong>UPDATE</strong>
  Changed the code to this:</p>
  
  <pre><code>    PromotionDetailViewController *pvc = [[PromotionDetailViewController alloc] initWithPromotionID:promo_id[@"promo_id"]];
      UINavigationController *promoNav =
      [[UINavigationController alloc] initWithRootViewController:pvc];
      self.window.rootViewController = promoNav;
  </code></pre>
  
  <p>Now the API call is successful, I am able to see the correct NAV bar, but the app crashes due to the below error:</p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception 'NSRangeException', reason:
    '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty
    array'</p>
  </blockquote>