Beginners Guide: Programming Cocoa for OS X
A few months back a friend asked me if I wanted to help work on a small application for OS X. He figured because I had a long history of Windows based programming I would have no trouble making the transition to writing apps for Mac. Well he was wrong for obvious reasons and I also found (unlike coding Windows apps) that the journey to bring my skills up to par for Mac, was a greatly rewarding, yet somewhat convoluted experience.
Back then I put the question to Mudi, one of the devs behind ForkLift, and he came through with some really great suggestions for me (thanks dude!). What follows are some beginner’s recommendations and a brief outline for those interested in learning to build wicked cool programs for Mac’s OS X.
First of all some background. Wikipedia says it better than I ever could:
“Cocoa is Apple Inc’s native object-oriented application programming environment for the Mac OS X operating system. It is one of five major APIs available for Mac OS X; the others are Carbon, Toolbox (for the obsolete Classic environment), POSIX (for the BSD environment), and Java. (Environments such as Perl and Ruby are considered minor environments because they are not generally used for full-fledged application programming.)
Cocoa applications are typically developed using the development tools provided by Apple, specifically Xcode (formerly Project Builder) and Interface Builder, using the Objective-C language. However, the Cocoa programming environment can be accessed using other tools, such as Python, Perl and Ruby, with the aid of bridging mechanisms such as PyObjC, CamelBones and RubyCocoa, respectively. It is also possible to write Objective-C Cocoa programs in a simple text editor and build it manually with GCC or GNUstep’s makefile scripts.
For end-users, Cocoa applications are considered to be those written using the Cocoa programming environment. Such applications usually have a distinctive feel, since the Cocoa programming environment automates many aspects of an application to comply with Apple’s Human Interface Guidelines.”
So if you are going to be learning to write next generation applications for OS X you will need the following:
- A strong background with Objective C
- A fluent understanding of Cocoa and the other APIs used to interact with OS X.
- Xcode (currently 2.4.1) – This is Apple’s app development environment, where you will be doing pretty much all of your work.
- Interface Builder (bundled with Xcode) – Can you guess what this does?
- A membership (free or paid) to Apple’s Developer Connection site.
- Some great textbook style books to get you off and running (my favorites reviewed below).
- A ridiculous amount of caffeine fueled beverages and an understanding spouse.
Objective C Books
Programming in Objective-C
by Stephen Kochan | $23.00
Written like a text book Kochan’s Programming in Objective-C is one of the best programming books I have ever read, and the book has a good reputation. I hadn’t done any work in C/C++ since the early 1990’s and I was honestly up to speed with Object Orientated C in no time. The book is positioned at beginners, so if you have zero experience in C or programming in general you should still be fine with this one, but you may need to re-read several chapters. Although he starts off fast with some fundamentals the author wastes little time with fluff and each chapter is really packed with information. Aside from a couple of errors (see below) the example code is also really well put together and clear in the principles it is trying to convey.
As this was recommended by virtually everyone as the only book to buy for learning Objective C it was the first one I picked up on the subject. I found that I came away with enough experience and confidence to push forward into Cocoa and get started building real Mac apps.
One problem I had with this book is that there were a couple errors in the exercises that had me a bit stumped. Luckily I found the errata on Stephen’s website. Another thing you should know is that this book does not go over Cocoa at all but it is somewhat implied that you will be wanting to build apps on OS X. So for the most part the book is not platform dependent in any way.
The bottom line is, you will not be much of a Mac developer without a strong background in Objective C, and this is the reference that will help you get there. Highly recommended.
Objective-C Pocket Reference
by Andrew M. Duncan | $27.63
I have always been a sucker for O’Reilly’s pocket quick reference guides. I found that having it available on my desk really helped me read Stephen’s Programming in Objective-C I recommend above. They are perfect companions. So keep in mind that this is a 128 page reference book covering stuff like syntax, objects, memory and exception handling, and not a text book. Having said that there were a few things I just didn’t grasp until they were outlined for me in this book. This guide really became an important desk reference once I started building.
I have no gripes with this book – clear, concise, inexpensive and easy to read.
Cocoa Books
Cocoa Programming for Mac OS X (2nd Edition)
by Aaron Hillegass | $26.93
This book is very well known in Mac development circles and that’s why I mention it first. It is likely the book that most developers read first once they have a foundation built in Objective C programming. The book serves as a very good introduction to the Cocoa framework and XCode, and provides some really well written examples. If you are just starting out I would really recommend this book as Aaron is honestly a very talented teacher. I went through the exercises in this book coming away knowing that I had really mastered the subjects covered.
However, don’t expect him to go too deep in to each concept, as he tends to gloss over a few things I wish were expanded on a bit. Also some people might say that the book is a bit dated and even though it is revised, there are a couple of areas it lacks. The book was written before Xcode 2.0 and a couple of the examples demonstrate that, but in all honesty, it’s not a big problem to overcome. I also wish Aaron had provided source examples somewhere online, but I guess forcing me to type the exercises out by hand makes them stick a bit better too.
All in all highly recommended for programmer’s switching over to Mac and other beginners.
Cocoa Programming
by Scott Anguish, Erik Buck, Donald Yacktman | $99.00
Cocoa Programming is a really large SAMS book that weighs in at nearly 5 lbs. Thankfully all of the bulk is not wasted on preaching or fooling around as this book has long been considered one of the best Cocoa books you can buy. People have told me that this book has really cleaned up any final issues or misconceptions they had using Cocoa, and really added to their toolsets.
I constantly found that the authors went above and beyond explaining the classes and protocols of Cocoa, and many of the examples I find actually using in my applications. You really get the sense that the guys writing the material are crack programmers with years of experience. The most interesting areas of the book for me were the sections on Client/Server networking, and some of the Appkit stuff (which they obviously cover in-depth).
The problem with this book is that it was written in 2002. So this is way back in the OS X 10.1-10.2 days, and some of what is covered is completely deprecated. This along with the hefty price were almost enough for me to not even consider buying it. The thing that redeems this book is that it covers valid subjects with entire chapters that newer books do not even mention. The truth is when it comes to actually sitting down and doing the work I find myself constantly coming back to this one.
Additional Resources
Well I hope this helps would be OS X programmers to get started. It really seemed daunting at first but you will be in the thick of things in no time. Some final web based resources I found invaluable:
- Again – Apple’s Developer Connection website, read this getting started guide. Check back often.
- The developer related areas of the Apple mailing lists were often useful.
- Andy Matuschak has a written an excellent friendly guide to getting started with Cocoa.
- Macdevcenter.com – This is the O’Reilly networks contribution to developing on Mac. An essential resource with regular updates.
- CocoaDev.com – A Cocoa resource site with an old school styles bulletin board.
- Cocoadevcentral.com – One of the best resources out there. Excellent tutorials and articles with reader comments in a blog styled layout. Both internal and external sources.
- The Mac programming forum on MacRumors has some great discussions with lots of active users.
- iDevApps is another popular and active forum for Mac developers.
- #macdev on Freenode, one of the biggest IRC channels for Mac development.
- There is even a podcast for Cocoa developers although it is becoming less and less updated.
- Update: Alex Clarke has pointed out his excellent Open Sourced project called BecomeAnXcoder. The PDF based guide is aimed at true beginners, comes in five languages, and is really very well written (I just printed it off). Thank’s Alex, not sure how I never came upon this.
What resources help you sharpen your OS X programming skills?

You don’t exactly need the books. There’s plenty of great documentation on ADC, that’s definitely book-grade. Of course, that is not to say that the books are a waste of money, just that you can get by without them.
Also, you don’t really need a strong foundation in Objective-C programming to use the Cocoa Programming for Mac OS X book. As it says in the preface, it’s written for programmers who already know some C programming and something about objects.
Thank you. I’ve been attempting to begin learning Cocoa and I’ve never quite found a good place to start. Please make this a series!
I too would love to learn OBJ-C, Cocoa, applescript etc. IN the grand scheme of things which do you recommend i learn first?
While I appreciate being called a great teacher, I’m not the author of Aaron’s book or coursework.
I do now work in the Cocoa and Developer Tools group in the Technical Publications department at Apple. We’re striving very hard to make the doc the best it can be.
Wooops…Thanks Aaron, fixed – was late when I typed this up. I still think you’re a great teacher
Actually, I’m Scott. Aaron wears the giant cowboy hat.
[...] Beginners Guide: Programming Cocoa for OS X | MacApper A few months back a friend asked me if I wanted to help work on a small application for OS X. He figured because I had a long history of Windows based programming I would have no trouble making the transition to writing apps for Mac. Well he was wrong for obvious reasons and I also found (unlike coding Windows apps) that the journey to bring my skills up to par for Mac, was a greatly rewarding, yet somewhat convoluted experience. [...]
[...] Beginners Guide: Programming Cocoa for OS X [...]
Don’t forget the free beginner’s guide, BecomeAnXcoder, which is available in 5 languages. (Shameless plug). It’s quite simple yet covers a lot of the basics, and assumes no prior programming knowledge. 70,000 downloads and counting…
You can get it from http://www.cocoalab.com/
Thanks!
Will have to try this out!!
Thank you. I’ve been attempting to begin learning Cocoa and I’ve never quite found a good place to start. and me too.
@Scott: LOL I did it again!
@Alex: Hey thanks for bringing BecomeAnXcoder to my attention, I just checked it out and it looks really impressive – wsh I had found this before! I added an update to my article referencing the project
[...] post by Doc Logic Share and Enjoy: These icons link to social bookmarking sites where readers can share and [...]
[...] Beginners Guide: Programming Cocoa for OS X (tags: mac programming cocoa Objective-C) [...]
[...] Beginners Guide: Programming Cocoa for OS X | MacApper (tags: programming cocoa osx) [...]
[...] Beginners Guide: Programming Cocoa for OS X | MacApper (tags: programming cocoa osx mac apple reference objective-c development) [...]
[...] Beginners Guide: Programming Cocoa for OS X | MacApper (tags: programming osx cocoa mac Apple objective-c) [...]
I would try a few on-line examples/tutorials using Cocoa Objective-C before buying the books. I would try the links mentioned above. Here’s a quick hello world sample.
http://macateeny.blogspot.com/2007/08/xcode-helloworld-in-less-than-minute.html
[...] I recently came across this article from someone who made the switch, and it seems like a pretty interesting thing to try out! Maybe in [...]
[...] * Beginners Guide: Programming Cocoa for OS X http://macapper.com/2007/09/16/guide-programming-cocoa/ [...]
[...] read more | digg story [...]
Hi,
This article has very useful information, it will be helpful for many. Actually one of my friends first read this article and asked me to visit this page.
It’s really amazing to read this description of this article. Thank you so much for your help and for your efforts.
Thanks,
Alex
http://www.NobleHelp.org
i realy need to learn pragramming can you help?
[...] you! home | incoming hURRLs | FAQ | download Voila, the hURRL you reqested …1 hURRLs – Beginners Guide: Programming Cocoa for OS X | MacApper (first hURRLed by mmathias @ 6 months ago /// permalink) mmathias says:”Programming Cocoa for [...]
[...] Tutorials und eBooks rund um Cocoa für Mac OS X umsehen. Die Links verweisen unter anderem zu MacApper, Andymatuschak, der Stanford-Uni und dem Cocoalab, helfen bei Startschwierigkeiten mit Apples [...]
I created a list of books for people getting started in OS X development, with my own impressions of each. You can find it on Amazon, here.
I disagree that the ADC is a one stop shop for resources. I have no previous programming or developing experience. I do admit that the ADC resources will have you making apps and such by copying code supplies to you. This teaches you how to associate objects through Xcode, but not the language behind it. I picked up Kochan’s book (Programming in Objective-C) and was able to write from scratch my first basic value calculating file and understand what it meant in just a few hours (well worth the money). As for getting a start in interface building (iPhone SDK), I have started using a screencast series from http://www.pragprog.com/screencasts. The guy really breaks down the steps to a beginner’s level like Kochan does in his book. This has worked great for me so far, try it out.
[...] read a word from him, but goodbye sir<br/> Woz Beginning Cocoa<br/> Very small Toy OS<br/> -m One Comment, Comment or [...]
Cocoa and iPhone Development (OS X)…
Project Configuration Creating and sharing an Xcode Project in SVN Xcode & SVN Books We have the following books on PDF ask Noel for latest updates. All of these are from Pragmatic Cocoa Programming: A Quick Start Guide for Developers…
Thanks for the good info. One minor point: I went to the Kochan web site, referenced here, to get the errata for “Programming in Objective-C,” but the links for not only errata but resources, code examples, answers, etc. all appear to dead-end, as if the site is no longer being maintained properly. If someone has a better experience, please post a follow up comment here – I will check back.
Also, my own impression of the Kochan book is somewhat less positive – it is not bad by any means, but not great either. For example he will present a topic like bitwise operations without giving the reader any clue whatsoever as to when these operations might be useful with modern processors and in the Cocoa environment. It is not enough to say that the reader should know this already by having a background in C. As with 99 percent of tech books, better editing was needed to help the author out.
This is a good web site:
http://masters-of-the-void.com/
I am using it to learn