Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to log an long long value with NSLog?

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... 
like image 979
openfrog Avatar asked Jan 24 '10 15:01

openfrog


People also ask

Where does NSLog write to?

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.

How do you print double values in Objective C?

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.

How do you print a boolean in Objective C?

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).


2 Answers

long long veryLong = // assume value here NSLog(@"My long long is: %lld", veryLong); // now it's right 
like image 150
David Kanarek Avatar answered Sep 17 '22 02:09

David Kanarek


The String Format Specifiers section of the String Programming Guide for Cocoa is a great bookmark for your browser ... ;-)

like image 35
Joshua Nozzi Avatar answered Sep 21 '22 02:09

Joshua Nozzi