NSLog the method name with Objective-C in iPhone

前端 未结 6 2116
自闭症患者
自闭症患者 2020-12-07 07:09

Currently, we are defining ourselves an extended log mechanism to print out the class name and the source line number of the log.

#define NCLog(s, ...) NSLo         


        
6条回答
  •  渐次进展
    2020-12-07 07:32

    To technically answer your question, you want:

    NSLog(@"<%@:%@:%d>", NSStringFromClass([self class]), NSStringFromSelector(_cmd), __LINE__);
    

    Or you could also do:

    NSLog(@"%s", __PRETTY_FUNCTION__);
    

提交回复
热议问题