Logging the class name of all UIViewControllers in a project

后端 未结 7 750
一生所求
一生所求 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:38

    Here is solution for this

    In your .pch file include this

    #define UIViewController MyViewController
    #import "MyViewController.h"
    

    Create your new UIViewController sub class as

    .h file

    #import <UIKit/UIKit.h>
    
    #ifdef UIViewController
    #undef UIViewController
    #endif
    @interface MyViewController : UIViewController
    
    @end
    #ifndef UIViewController
    #define UIViewController MyViewController
    #endif
    

    And .m file

    #import "MyViewController.h"
    
    @implementation MyViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        NSLog(@"Current View Class: %@", NSStringFromClass(self.class));
    }
    
    @end
    
    0 讨论(0)
提交回复
热议问题