Skip to Content

Listen to the Joystiq Podcast (because your ears can't read)
AOL Tech

NSLog posts

Filed under: iPhone

iPhone Coding: NSLog on the iPhone

NSLog provides one of the most important debugging tools for your iPhone arsenal. Unlike its Cocoa equivalent, the iPhone NSLog sends information to the command line. It's basically a printf for NS and UI objects. To print an NSString, for example, you might use NSLog(@"String is %@", mystring);. When this line executes, the results print out almost as if you had done a printf("%s", [mystring cStringUsingEncoding:1]); with an extra bit of date and time information attached. Use %@ for objects. Otherwise use the standard C formatting codes: %d for integers, etc.

You will only be able to see NSLog results when your iPhone applications are launched from the command line. Launching them from SpringBoard hides the NSLog information.

The iPhone Crash Reporter provides important information about failed program execution. Go to /Library/Logs/CrashReporter to see dumps from the most recent crash. Dumps are in the form of property list files, which you can open in a text editor or in Apple's Property List Editor.

Tip of the Day

Holding the Command key (aka the Apple key) and pressing Tab will cycle through your open applications. It's easier to Cmd-Tab if you are Copy (Cmd-C) and Pasting (Cmd-V) to and from various applications.


Follow us on Twitter!
TUAW [Cafepress]

Sponsored Links

Featured Galleries

DNC Macs
Macworld 2008 Keynote
Macworld 2008 Build-up
Google Earth for iPhone
Podcaster
AT&T Navigator Road Test
Bento for iPhone 1.0
Scrabble for iPhone
Tom Bihn Checkpoint Flyer Briefcase
Apple Vanity Plates
Apple booth Macworld 07
WorldVoice Radio
Quickoffice for iPhone 1.1.1
Daylite 3.9 Review
DiscPainter
Mariner Calc for iPhone
2009CupertinoBus
Crash Bandicoot Nitro Kart 3D
MLB.com At Bat 2009
Macworld Expo 2007 show floor
Apple Texas Hold 'Em

 

More Apple Analysis

AOL Radio TUAW on Stitcher