title: Navigation change doesn't get triggered when calling it inside callback block
body: <p>I have the task of making some small adjustments in a bigger Objective-C app.</p>
  
  <p>What I'm trying to do is when the user clicks on an item in a list, a calculation will be executed and depending on the outcome, the navigation should pop back to root and display an error. Because I do not have access to the NavigationController in the class where the calculation is done, I tried to pass a "callback block".</p>
  
  <pre><code>[self.baseBehaviour processInfo:info completion: ^(BOOL finished) {
    NSLog(finished ? @"YES" : @"NO");
    // pop back to root controller
    [self.navigationController popToRootViewControllerAnimated:YES];
   }];
  </code></pre>
  
  <p>I pass that block along until the calculation is done and call the callback. It seems to work fine because I can see YES or NO in the logs, but the navigation is not triggered for some reason. It also does not seem to be a scoping issue because self seems to be the same reference (and I even tried to make a new variable for the navigationController, but that didn't help either).</p>
  
  <p>If I take out <code>[self.navigationController popToRootViewControllerAnimated:YES];</code> and move it out of the callback (so it gets executed immediately), it works perfectly. But obviously that doesn't help me because at that time I did not determine if I need to go back or not.</p>
  
  <p>Am I missing something obvous or is there a way to see (in the debugger) why the animation doesn't get triggered?</p>
  
  <p>Thanks for your help.</p>
  
  <p>EDIT:</p>
  
  <p>I was trying this while testing, but it also didn't seem to work:</p>
  
  <pre><code>    [self.baseBehaviour processInfo:self.info completion: ^(BOOL finished) {
          dispatch_async(dispatch_get_main_queue(), ^{
              NSLog(finished ? @"YES" : @"NO");
              // pop back to root controller
              [self.navigationController popToRootViewControllerAnimated:YES];
          });
      }];
  </code></pre>
  
  <p>EDIT2:</p>
  
  <p>It looks like it could be a scoping problem after all. I noticed that when I did `` then it was nil in the debugger.</p>
  
  <pre><code>NSArray *viewCtrls = [self.navigationController viewControllers]; // 3 elements
  
  [self.baseBehaviour processInfo:self.info completion: ^(BOOL finished) {
      dispatch_async(dispatch_get_main_queue(), ^{
          NSLog(finished ? @"YES" : @"NO");
          // pop back to root controller
          NSArray *viewCtrls = [self.navigationController viewControllers]; // nil
          [self.navigationController popToRootViewControllerAnimated:NO];
      });
  }];
  </code></pre>
  
  <p>How can I "pass" something into the callback block, like the navigationController?</p>