_cmd可以获取当前的方法selector
_cmd在Objective-C的方法中表示当前方法的selector
比如我们打印当前的方法名可以这样写:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"Current method: %@",NSStringFromSelector(_cmd));
}
统计的字符串
[NSString stringWithFormat:@"%@:%@",[self class],NSStringFromSelector(_cmd)]
网友评论