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

Categories

0 votes
832 views
in Technique[技术] by (71.8m points)

iphone - Difference between NSLog and Printf statement for ObjectiveC

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

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

1 Answer

0 votes
by (71.8m points)
  • 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...