Logging Messages
For novice developers, the first line of defense against bugs is to just write messages to the console to see what’s going on. We’ve been doing this with the print function 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 print is that it will print a message to the console that only we will see. (Foundation also has an NSLog function that provides a timestamp and the process name of the app.) 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.
Let’s put ourselves in a situation where we might ...