Print out the variable name objective-C

前端 未结 1 1507
不知归路
不知归路 2020-12-05 01:14

Continued from the last question here: Log method name in Obj-C . I just wondered if there is a way to print out the variable name as well. For example:

NSS         


        
相关标签:
1条回答
  • #define logIntVariable(x) NSLog( @"Value of %s = %d",#x, x)
    
    
    - (void) myRoutine {
       int intValue = 5;
    
       logIntVariable(intValue);
    }
    
    0 讨论(0)
提交回复
热议问题