Use the following code:
#define stringVariable(x) NSLog( @"%s:%@",#x, x)
NSString *myString=@"Welcome";
stringVariable(myString);
Note. . The general principle is that when you put # in front of an argument inside the body of #define, the preprocessor replaces it with the string C of the exact expression passed in the macro. When you pass the variable name, you get that name.
source
share