I am on a delegate of a NavigationControl based app.
when I try to access the rootViewController using
RootViewController *rootViewController = (RootViewController *)[navigationController topViewController];
to run a method, it crashes, saying the method is "unknown" on the rootViewController.
When I access the rootViewController using this
RootViewController *rootViewController = (RootViewController *)[navigationController.viewControllers objectAtIndex:0];
it works.
Which object is the first line accessing?
thanks
topViewController
of a navigation controller represents the view controller at the top of the stack. Index 0
is the bottom. topViewController
is the object at index 0
only when one view controller is on the stack. If you have more than one, it is not the same. I am guessing that it is the case as it's crashing because the topViewController
doesn't know how to respond to messages intended for a RootViewController
instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With