Get Updates By E-mail 

Article Written By:
Johann Dowa

Easier Debugging With NSLog Statements

Something that comes up frequently, and something I’ve had difficulty in the past with myself is debugging iPhone apps.  There is a fairly easy way to alleviate that problem, and that is to place NSLog statements that print out the name of the method, class, whatever information you like to the console so that you can find out the problem area of a program, however there is a big problem with NSLog statements, and that is that they seem to use a an overly large amount of system resources.

I’m not exactly sure why it is, but I’ve found NSLog statements can really slow down a program, and having any running in the release version of your app (even though there’s no console displayed) seem to have a dramatic impact upon performance.  So you will want an easy way to turn them on, or off. 

Unfortunately, this is generally done by placing #ifdefs all over your code so that the NSLog statements are not compiled out of debug mode, but I have found a better solution.

Karl Kraft has created a debuglog statement that does everything that NSLog does, but turns off outside of debug mode.

You can download the full project here: Debuglog

The details on how to use Debuglog are included in the link on Karl’s blog.  Check it out, and it will speed up your debugging, you can even better the details of NSLog statements easily.

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.