Search code examples
iphoneiosviewuiviewcontrollercontrollers

count view controllers


I can't seem to get the number of view controllers in the view controller stack.

NSUInteger *viewControllerCount = self.navigationController.viewControllers.count;

I can loop through the view controllers and NSLog the objects within but I can't do a simple count. If I try to access this pointer, the ap crashes... no Log, no error message, nada. Please help!


Solution

  • I believe you want to remove the *:

    NSUInteger viewControllerCount = self.navigationController.viewControllers.count;