iOS NSLog usage tips

When developing and debugging, you often need to print some information for debugging. When there are too many places to print information, the output content on the device will greatly affect the device performance. You can use macros to control the output of these debugging information.

#ifdef __OBJC__
 
#ifdef DEBUG
#define JSLog(fmt,...) NSLog((@"%s [Line %d] "fmt),__PRETTY_FUNCTION__,__LINE__,##__VA_ARGS__)
#else
#define JSLog(...)
#endif

#endif

Some printing methods of different types:

NSLog(@"NSString type: %@",name);

NSLog(@"int data: %i",number); //or %li; %ld; %d

NSLog(@"Chr type: %c",xxx);

NSLog(@"Float type: %f",xxx);

NSLog(@"Double type: %.2f",xxx);

NSLog(@"BOOL type%@",xxx);

Guess you like

Origin blog.csdn.net/JustinZYP/article/details/124569644