xcode AppDelegate.m 中当前 ViewController 类名的 NSLog
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13409009/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:06:44 来源:igfitidea点击:
NSLog of the current ViewController class name from AppDelegate.m
提问by RollRoll
How can I generate NSLog from the current ViewController class name?
如何从当前的 ViewController 类名生成 NSLog?
- (void)applicationWillResignActive:(UIApplication *)application
{
NSLog(self.window.rootViewController.class);
}
回答by fannheyward
Try this:
尝试这个:
NSLog(@"%@", NSStringFromClass(self.window.rootViewController.class));
回答by Edwin Iskandar
if you're using a navigation controller you probably want something like this:
如果您使用导航控制器,您可能需要这样的东西:
NSLog(@"%@", [self.window.rootViewController.navigationController.visibleViewController class]);