iOS Development: What are the reasons for [[self navigationController] viewControllers]; would he return nothing?

advertisements

the following statement is returning an nil...

NSArray *viewControllersInNavStack = [[self navigationController] viewControllers];

and this statement is being called in a view controller that's about four levels deep in the navigation stack, so I don't understand how or why it would ever return nil. Your thoughts?

Thanks so much for your wisdom!


Doesn't sound like its your issue, but docs say "Only returns a navigation controller if the view controller is in its stack. This property is nil if a navigation controller cannot be found".

First check if [self navigationController] is returning nil. If not, then viewControllers] must, but break it down first.