Because the childViewControllers of navigationController is a stack,
So use this function, you can pop to f viewController and the " c > c > c > c" was destroyed.
for (UIViewController *tempVC in self.navigationController.childViewControllers) {
if ([tempVC isKindOfClass:[fViewController class]]) {
fViewController *f = (fViewController *)tempVC;
[self.navigationController popToViewController:f animated:YES];
}
}
However, if you don't want to pop to f, just want to get the new childViewControllers of navigationController. you can use next functions:
for (UIViewController *tempVC in self.navigationController.childViewControllers) {
if ([tempVC isKindOfClass:[ScanViewController class]]) {
NSUInteger findex = [self.navigationController.childViewControllers indexOfObject:tempVC];
NSMutableArray *viewArray = [NSMutableArray arrayWithArray:self.navigationController.childViewControllers];
[viewArray removeObjectsInRange:NSMakeRange(findex, viewArray.count - 1)];
}
}
The viewArray is the new childViewControllers.And if you have new demand, can edit this function then use it.