Cocoa-Matic

iPhone, iPod touch, iPad tutorials, examples and sample code. Come and get it!

Wednesday, August 4, 2010

Better NSLog implementation

NSLog is an invaluable tool for developers who are looking to debug and/or troubleshoot code. It outputs to the debugger console during the application runtime. Before I show a better way to use the NSLog function, let's go over the basics with an example:

int myInt = 100;
NSLog(@"The value of myInt: %i", myInt);
This will output:
The value of myInt: 100

Depending on what type of value you're trying to print, you'll have to use different Format Specifiers (%i in the previous example). Here's a list of common Format Specifiers:
Read more »

Labels:


« Older Entries