标签:style ar color sp strong on log cti bs
我们知道self表示当前类的一个实例。可以调用方法,访问属性。
那么_cmd是什么呢?
Apple官方文档是这么说的。
The _cmd variable is a hidden argument passed to every method that is the current selector.
翻译: _cmd 参数是一个隐藏参数 ,用来传递当前的selector(方法);
验证一下:
假设我们有一个类叫MyObject 有一个Share方法
+(void)share{
NSLog(@"Current method: %@ %@",[self class],NSStringFromSelector(_cmd));
}
打印结果为 MyObject share
标签:style ar color sp strong on log cti bs
原文地址:http://www.cnblogs.com/ZippoatiOS/p/4126070.html