I came across a piece of code that needs to be placed in a specific view manager in the navigation stack, as shown below.
for (UIViewController* viewController in self.navigationController.viewControllers) {
if ([viewController isKindOfClass:[MyGroupViewController class]] ) {
MyGroupViewController *groupViewController = (MyGroupViewController*)viewController;
[self.navigationController popToViewController:groupViewController animated:YES];
}
}
The goal is pop to MyGroupViewController. But I do not understand this line of code.
MyGroupViewController *groupViewController = (MyGroupViewController*)viewController;
What's going on here? I do not think that a new instance of MyGroupViewController is being created here.
source
share