iOS 如何知道查看当前控制器是哪个控制器

给控制器 增加分类

+ (void)load
{
#ifdef DEBUG
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        Class cls = [self class];
        Method m1 = class_getInstanceMethod(cls, @selector(viewDidAppear:));
        Method m3 = class_getInstanceMethod(cls, @selector(viewDidAppear_EverPath));
        method_exchangeImplementations(m1, m3);
    });
#endif
}

- (void)viewDidAppear_EverPath
{
    [self viewDidAppear_EverPath];
    NSLog(@"当前VC控制器:%s\n",NSStringFromClass(self.class).UTF8String);
}

你可能感兴趣的:(iOS 如何知道查看当前控制器是哪个控制器)