title: Difficulty with pushViewController pushing two levels at once
body: <p>I have a list of items in one view controller. I can select an item and a detail view controller is pushed to show details of the selected item. I can then select the edit button (from the nav bar) and an edit view controller is pushed to allow me to edit the details of the item. All of this is working, including cancel and undo.</p>
  
  <p>In the first list view controller, I also have an add button (in the nav bar), where I can add a new record. (This is using core data, but I don't think that has relevance to my question.) I started testing by creating a blank record for the item, and when the detail view controller appears, all of the fields are blank. Then I can select the edit button and edit the details, just as if it were an already populated record. This also works.</p>
  
  <p>What I have been trying to do is select the add button and push the detail view controller  and then the edit view controller immediately. The reason I want to do this is so that when I pop the edit view controller, the detail view controller will show. (Then I can pop back to the list view controller or push into the edit view controller again.)</p>
  
  <p>I am having trouble with this.</p>
  
  <p>I tried two pushes in the list view controller, like this:</p>
  
  <pre><code>- (void) add {
      clientInfoTVC.clientMO = [self createNewClient];
      [self.navigationController pushViewController:clientInfoTVC animated:YES]; 
      [self.navigationController pushViewController:clientInfoTVC.clientEditTVC animated:YES]; 
  }
  </code></pre>
  
  <p>where clientInfoTVC.clientEditTVC points to the eidt view controller. This errors SIGABRT and  halts when I try an add.</p>
  
  <p>I then tried setting a flag property value in the detail view controller when add is selected, before the first push and then doing a second push in viewWillAppear of the detail view controller. This errors out. I tried moving the second push to the viewDidAppear of the detail view controller, with the same results.</p>
  
  <p>I am lost on this one. Can someone give me some ideas how to push through one view controller to the second one, so that I can maintain the navigation stack and pop back to the middle view controller?  </p>
  
  <hr>
  
  <p>@ljkyser hit on part of the answer. But I also found that simply pushing a view onto the stack does not get it to execute its init, viewWillAppear, and viewDidLoad. I am guessing that since all of this is happening on the main thread, then pushing a view just queues that view controller onto the run loop. Pushing a second view controller removes the first from the run loop and puts the second view controller in the run loop queue. Maybe someone can verify that and describe it more accurately than I just did.</p>
  
  <p>In any case, to get the edit view controller initialized properly, I had to pass a pointer to it, so it can find the managed object it is working with. I had originally instantiated the edit view controller from within the detail view controller. Therefore, in my original code, I was pushing a view controller that was not instantiated yet. To be safe, I instantiated it from the list view controller, and then made sure all of the managed object pointers were set up before I did the double push, like this:</p>
  
  <pre><code>- (void) add {    
      Client *clientNew = [[NSEntityDescription alloc]  init];
      clientNew = [self createNewClient];
      clientInfoTVC.clientMO = clientNew;
      clientEditTVC.clientMO = clientNew;
      [clientNew release];
      [self.navigationController pushViewController:clientInfoTVC animated:NO]; 
      [self.navigationController pushViewController:clientEditTVC animated:YES]; 
  }
  </code></pre>
  
  <p>Confirming the answer given by @ljkyser, I tried these changes while keeping the first animated:YES. With this, the nav bar looked right, but the rest of the view was out of sync. Setting animated:NO fixed that problem.</p>