Browsing articles tagged with " NSLog"

How to Log to the Console Using NSLog

Dec 22, 2009   //   by Derek van Vliet   //   Development  //  1 Comment

Xcode has a built in console that provides an invaluable debugging tool for iPhone app development. It gives you a way to monitor text output from your app live at runtime. It works both for apps being debugged in the simulator and on a device.


Logging statements to the console is just as easy as you would expect it to be in iPhone app development. Just run the NSLog function like so:

NSLog(@"hello world");

Format Specifiers

The NSLog statement also supports string formatting specifiers, so you can also output the values of variables to the console with just one line. Below are some examples:

NSString * str = @"hello world";
NSLog(@"%@", str);
int num = 10;
NSLog(@"%i", num);
float price = 1.99;
NSLog(@"%f", price);

Our Games

Latest Tweets