Tools of the Trade: Learning Objective-C from Scratch

Learning a new language is never a simple task, but the process itself shouldn’t be difficult. For my Master’s final project, I’m teaching myself Objective-C. (More on our decision to go native here.) For those facing a similar task, here are some tools I’m using using to facilitate this process.

Learning Materials

I researched several learning resources that had been recommended on Quora, including Big Nerd Ranch’s iPhone Programming and Craig Hockenberry’s iPhone App Development: The Missing Manual.

In the end, I decided to “take” the Stanford iPhone Application Development course, which is available in its entirety on iTunes U. (Note that iTunes U has both the 2009 and 2010 courses. I chose the 2010 version because a) it’s geared for a newer iOS SDK, and b) all the supporting materials are still (as of Spring 2011) available on Stanford’s course website.

iTunes handles the lecture downloads, but I watch them with QuickTime Player for two reasons: it uses less screen real estate, and you can speed up playback by option-clicking the fast-forward button. A text editor is ideal for notes (particularly one that handles Obj-C syntax highlighting), and it’s always handy to keep the lecture slides open as well. Here’s my typical “class time” screen:

Screen shot 2011-02-27 at 10.29.51 PM.png

Helpful shortcuts:

  • Setting up the screen like this is a snap with Divvy. I set up shortcuts to move windows to each half or quadrant of the screen, so they can fly to any position with a keyboard shortcut. Priceless.
  • A series of quick-and-dirty AppleScripts—which can be quickly invoked with FastScripts—makes it easy to work the lecture files. Scripts I use (available on Github) include:
    • launch the current iTunes file in QuickTime Player (or vice-versa), retaining the current playback spot
    • jump to an arbitrary playback position in QuickTime Player (especially helpful if I’ve been watching a video on my iPhone)
    • jump backwards or forwards in QuickTime Player

Notekeeping

Right now I keep two types of notes: course notes and error notes.

Course notes—general notes from the lectures or books—go in a single text file that’s easily searchable. I type or copy most of the lecture slides into this document because it’s easier to have it all in one place.

Error notes, which detail all the build errors I get in Xcode, live in Notational Velocity (tagged with “ObjC” and “Error”). Each error note contains the following sections:

  • Error message
  • Context (anything that might help)
  • My code (specific code throwing the error, and which file)
  • Problem explanation (interpretation of what went wrong)
  • Solution (fixed code)

These error notes are a personal history of the mistakes I’ve made. My expectation is that this practice will have value both now and in the future, but as the good folks at Field Notes say, “I’m not writing it down to remember it later, I’m writing it down to remember it now.” The more I can internalize beginner’s mistakes, the less likely I’ll be to repeat them.

My only complaint w/r/t using Notational Velocity for this purpose is that it doesn’t have syntax highlighting. A relatively minor inconvenience, but I’m hopeful that a future NValt build might include this.

Helpful shortcut: I use a TextExpander shortcut to pre-fill each error note before I start adding data. It simply adds each section’s header—something that might not seem that important, but it saves a little time and helps me be consistent in this practice.

Troubleshooting

Stack Overflow is an indispensable Web site for programming questions/answers. I should probably get better at perusing Xcode documentation, but often it’s faster to search Stack Overflow. (I’ve noticed that most of my problems are answered in Stack Overflow questions with no upvotes, meaning that they’re beginner errors. I’ll know I’ve arrived when I graduate to more popular questions!)

Helpful shortcut: Searching Stack Overflow is nearly instantaneous using a LaunchBar search template set to search StackOverflow with the [Objective C] tag pre-filled. Once it’s set up, ⌘[space] → “so” → [query] gets it done pronto.