_cmd

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容