NSLog(): The First Line of Defense Against Bugs

If you’ve spent time among other iOS developers or gone on Stack Overflow, you’ve probably heard someone mention the NSLog method, or perhaps println, a more primitive Swift logging function. This is the first—and often the last, unfortunately—piece of debugging advice new developers receive. We first saw it way back in for Loops, and have used it occasionally throughout the book, usually as a placeholder to make sure our app reached the new code we were writing.

The gist of NSLog is that it will print a time-stamped message to the console that only we will see. It might seem counterintuitive to create output that only we will see, but it is vitally important to have some means of verifying ...

Get iOS 9 SDK Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.