Logging the class name of all UIViewControllers in a project

后端 未结 7 790
一生所求
一生所求 2020-12-28 22:51

We have received a HUGE project from outsourcing that we are trying to \"repair\". There are hundreds of view controllers within the project. Our goal is to

7条回答
  •  攒了一身酷
    2020-12-28 23:16

    Does the app use Navigation controllers to display the View Controllers? If so, you can use the NavigationController's methods to report the current controller:

        - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
        {
            [self reportNewController:viewController];
        }
    
        - (void) reportNewController:(UIViewController *)viewController
        {
            NSString *name = viewController.title;
                NSLog(@"Name is %@",name);
        }
    

提交回复
热议问题