Call a macro every time any method is called - Objective C

后端 未结 4 1249
情深已故
情深已故 2020-12-06 07:46

I wrote a debug macro that prints to the console the passed-in string whenever the global kDebug flag == YES.

I need to print out the name

4条回答
  •  清歌不尽
    2020-12-06 08:21

    I ended up with this code, after asking a similar question here How can I log names of each called class method in Objective-C?

    - (BOOL)respondsToSelector:(SEL)aSelector {
        if(aSelector){
            NSLog(@"%@", NSStringFromSelector(aSelector));
        }
        return [super respondsToSelector:aSelector];
    }
    

提交回复
热议问题