How can I do that? What's the format specifier?
For example, I have:
long long veryLong = // assume value here NSLog(@"%f", veryLong); // of course wrong...
NSLog outputs messages to the Apple System Log facility or to the Console app (usually prefixed with the time and the process id). Many of the system frameworks use NSLog for logging exceptions and errors, but there is no requirement to restrict its usage to those purposes.
We can print the double value using both %f and %lf format specifier because printf treats both float and double are same. So, we can use both %f and %lf to print a double value.
There is no format specifier to print boolean type using NSLog. One way to print boolean value is to convert it to a string. Another way to print boolean value is to cast it to integer, achieving a binary output (1=yes, 0=no).
long long veryLong = // assume value here NSLog(@"My long long is: %lld", veryLong); // now it's right
The String Format Specifiers section of the String Programming Guide for Cocoa is a great bookmark for your browser ... ;-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With