Dynamically retrieving current method's name

前端 未结 3 2033
谎友^
谎友^ 2020-12-25 14:56

I\'d like to be able to put trace messages of the current class name and method name for all classes in my project.

Is there a way to get the current method\'s name

3条回答
  •  失恋的感觉
    2020-12-25 15:19

    NSLog(@"method name: %@", NSStringFromSelector(_cmd));
    

    _cmd is a hidden argument (like self) that all Objective-C methods receive. Its value is the selector that was used to call the method.

提交回复
热议问题