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