Learning Cocoa for the iPhone

These last few weeks, I’ve been teaching myself Cocoa to learn what makes Mac OS X and iPhone OS apps tick. While Objective-C is quite a departure from my usual web development world, Cocoa has quickly become one of my favorite languages, as it takes care of much of the drudgery of pure C and has plenty of useful frameworks to get your application up and running quickly. Here are some of the best resources I’ve found so far:

  • Cocoa Dev Central and Become an Xcoder are both excellent tutorials for beginners, written in a clear, straightforward manner. They also explain the ins and outs of memory management, which is critical on platforms like the iPhone and iPod touch.
  • Stanford’s CS193P lecture notes and examples have proven to be one of the best resources for learning Cocoa, particularly for the iPhone. These notes and tests offer Cocoa Touch in bite-size chunks, with a little bit of “on your own” work to ensure you know your stuff before moving on.
  • Google Code Search is a good last resort for examples of how others are using a small bit of code or a particular class. For more accurate results, append “lang:objectivec” to your search string to narrow results to only Objective-C code.
Advertisements
Learning Cocoa for the iPhone

Consolas Cursor Fix

If you’ve attempted to use Consolas as your choice programming font on the Mac, you may have noticed (as I did) an odd issue with the font, where your blinking cursor hangs much lower than the current line. Oddly enough, this little issue only seems to affect Mac OS X. Even the Consolas set that ships with Microsoft Office 2008 has the same problem! Yet, when the same exact font file is used under Windows, the cursor position is correct.

John Gruber mentioned that BBEdit 9.1 now ships with Consolas as its default font, so I decided to see if it had the same cursor problem I had experienced in the past. As it turns out, BBEdit’s version of Consolas works just fine, as seen in the image above. However, it doesn’t include the other styles like Consolas Bold, Italic, and Bold Italic.

Through one way or another, the copy of Consolas that ships with BBEdit 9.1 is different than the one that ships with Microsoft Office 2008. To make system-wide use of the working version, download BBEdit 9.1, mount and open the .dmg, and navigate to:

(Control-click BBEdit, and choose “Show Package Contents” to get inside the application bundle): BBEdit.app/Contents/Resources/Fonts/consola.ttf

Copy consola.ttf from BBEdit’s “Fonts” folder to your own Fonts folder at /Users/you/Library/Fonts, or /Library/Fonts if you want to make it available to everyone who has an account on your computer. Then, fire up your favorite editor, set Consolas as your preferred fixed-width font, and get coding!

Update: Bare Bones has apparently changed the version of Consolas that ships with BBEdit versions later than 9.1, and they now have the cursor problem as well…

Consolas Cursor Fix