println: 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 println method or its Objective-C predecessor, NSLog. This the first—and often the last, unfortunately—piece of debugging advice new developers receive. We first saw it way back in Logging, 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 println is that it will print a 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 what is happening in our program.

Get iOS 8 SDK Development, 2nd Edition 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.