_cmd

作者: goyohol | 来源:发表于2017-06-12 21:36 被阅读6次

Apple的官方介绍:“The _cmd variable is a hidden argument passed to every method that is the current selector”
翻译:“_cmd”在Objective-C的方法中表示当前方法的selector。如同self表示当前方法调用的对象实例一样。


🌰:打印当前类 及 要调用方法

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSLog(@"Current class:%@         Current method:%@",[self class],NSStringFromSelector(_cmd));
}


输出结果:














goyohol's essay

相关文章

网友评论

      本文标题:_cmd

      本文链接:https://www.haomeiwen.com/subject/qluqqxtx.html