Friday, May 6, 2011

Getting current method name in objective C

Following code fragments shows some useful tips of NSLog method. __PRETTY_FUNCTION__ identifier is used to get current method name.
You can display hexa values using NSLog method with %x formatter.
NSLog(@"Hex value: 0x%08x", 0x1234);

You can even get current method name in execution using NSLog method.

NSLog(@"%s", __PRETTY_FUNCTION__, nil);