NSLog vs printf
suggest changeNSLog(@"NSLog message");
printf("printf message\n");
2016-07-16 08:58:04.681 test[46259:1244773] NSLog message
printf message
NSLog outputs the date, time, process name, process ID, and thread ID in addition to the log message. printf just outputs the message.
NSLog requires an NSString and automatically adds a newline at the end. printf requires a C string and does not automatically add a newline.
NSLog sends output to stderr, printf sends output to stdout.
Some format specifiers differ between printf and NSLog. To include a string:
NSLog(@"My string: %@", (NSString *)myString);
printf("My string: %s", [(NSString *)myString UTF8String]);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents