Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to know about the difference between the NSLog and the Printf statement in Objective-C (for application purpose...!)

Why do all developer use NSLog instead of Printf ?

Both look similar, but what is the difference in internal working?

At which point can they be differentiated ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
802 views
Welcome To Ask or Share your Answers For Others

1 Answer

  • printf() is a C standard library function, accepting a C string constant (const char *) as its format argument. printf() writes to stdout.

  • NSLog() is a Foundation function, accepting a constant NSString as format, and has an extended format specifier set (for example, printf() does't print objects specified by %@, NSLog() does). NSLog() also prints the process name and date before it prints the actual format and writes to sdterr.

Basically, we can say that NSLog() is an extended printf() Style function for Objective-C (more precisely, Cocoa and Cocoa Touch) and specific purposes.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...