从AppDelegate.m访问当前ViewController类名

时间:2013-07-24 03:50:53

标签: objective-c

如果我想访问当前视图控制器而不是根视图控制器以从AppDelegate.m获取类名?

目前,ViewController A实际上是RootViewController的根视图。

我在这里做了一些研究但是我只设法获得了RootViewController类名而不是ViewController类。

NSLog of the current ViewController class name from AppDelegate.m

我已经按照提供问题的答案,但它返回null 自

NSLog(@"Current View Controller Class Name: %@", self.window.rootViewController.navigationController.visibleViewController.class);

NSLog(@"Current View Controller Class Name: %@", [self.window.rootViewController.navigationController.visibleViewController class]);

1 个答案:

答案 0 :(得分:0)

你试过这个......

NSLog(@"Current View Controller Class Name: %@",NSStringFromClass(self.window.rootViewController.navigationController.visibleViewController.class));
相关问题