It’s a strange irony: Cocoa makes writing feature-filled apps so easy, but it’s really quite hard to pick up how to use it! You might start with the Currency Converter or some other basic tutorial, but it’s very difficult to get the big picture; where do you go from there? None of the printed books currently available will ground you in the more recent parts of Cocoa that make it really unique.
Print this article out and fold it up along the dotted lines. If you do it just right, this text will become a tiny flashlight in a dark forest of dangerously obsolete literature.
Diverging Paths
Where exactly you begin depends on your level of experience thus far. Cocoa is made to be used with Objective-C, which is an extension of C.
If you’ve never programmed at all, this isn’t what you want. Danger! Programming is about solving problems in a way the computer can understand. C is a very powerful language, and using it will teach you many important things about the architecture of your system, but trying to learn a tricky language, programming, and computer architecture all at once is a bad idea. Try starting with Ruby to get some practice programming.
If you’ve programmed, but not with C, this tutorial by Scott Stevenson will give you the basics you need to get up to speed.
If you’re at least conversational in C, you’re ready to get started.
Baby Steps
Now, don’t let this scare you, but I’m going to just come out and say it: Cocoa is huge. It consists of a great number of frameworks that can accomplish just about anything you need in application development.
So any attempt to “learn Cocoa” is going to result in disappointment. We’ve just got to get you on your feet and show you how to find answers. We’ve got to give you a Cocoa intuition. I have no idea how to use Bonjour, for instance, but I’m sure I could use it in an app today if I wanted to. That’s what we’re aiming for.
The Lesson Plan: an Overview
There are two kinds of sources for information on Cocoa: tutorials and documentation. Most people start with a tutorial. But then what? You only really know understand how to do what’s in the tutorial. To gain a Cocoa intuition, you’ve got to understand how everything works under the hood.
But documentation is really boring. Apple’s Getting Started with Cocoa page is going to link you to a bunch of dry reference. You start on that path, and there’s no way you’re going to hold an interest long enough to learn anything useful.
We’ve got to get you excited.
Everything you need is already out there; I’m just pulling it together. I’m going to give you links to tutorials—little recipes for little tasks—followed by links to documentation. But you’ve got to promise to read all the documentation I give you very carefully, since I’m essentially just giving you the Cliff’s Notes.
We’re going to be using a lot of tutorials from Cocoa Dev Central because they’re excellent. If you find the tutorials useful, please consider donating to their author, Scott Stevenson.
Lesson One: A Taste of What’s to Come
Reading 1.01: “Learn Cocoa” at Cocoa Dev Central
You will write no code in this tutorial, but it’ll give you a little taste of Cocoa’s power. Don’t feel like you really need to learn anything from this; just get a little bit familiar with Interface Builder. Play around a bit. Try some different controls. See what they do.
If you are using Leopard, things will get a little difficult here due to massive changes in Interface Builder.
Reading 1.02: “Learn Cocoa II” at Cocoa Dev Central
Aha! I have tricked you! There is a little bit of documentation here, too. If you have never used an object-oriented language before, this will give a basic overview, and it will provide a basic overview of Objective-C syntax. You will write your first Cocoa-based code in this tutorial, and you will make something actually happen.
Lesson Two: Now for Some Understanding
Okay, you’ve had some fun. Now you’re going to actually learn something. Read the following documents carefully and thoroughly.
Reading 2.01: “What is Cocoa?: The Cocoa Environment” at Apple
Reading 2.02: “What is Cocoa?: Features of a Cocoa Application” at Apple
Reading 2.03: “Object-Oriented Programming” at Apple (if you’re new to objects)
Reading 2.04: “The Model-View-Controller (MVC) Paradigm” at Apple
Lesson Three: Mad Scientist
Alright, so you know how to send messages to objects. You know how to make buttons do things. That’s enough for now—no more reading. I’m throwing you in the deep end!
I want you to start by remaking the Clear Text example in Learn Cocoa II. But this time, do it without looking at the tutorial, at least as much as possible.
Now you’ve got that working, but we’re going to do something else. Make the button a Hello! button. It makes the text field say hello the user when clicked. But you don’t really want the user typing in the field for this program—figure out how to keep them from doing that by exploring the inspectors in Interface Builder.
We’ve got the computer saying hello, but we really want to open a line of communication. Here’s your task:
Add a text field above the big text view, move the button up, and add some text, so your window looks like this:

Okay. That’s the easy part. Now the hard part! When you fill in your name and click the button, this should happen:

This would actually be a lot easier in other languages, but I’m making things hard for you on purpose. Now, how do you do this? Well, you’re not getting any step-by-step instructions here. You’ll only learn by doing. But first, I’m going to give you a glorious tool that will let you find the info you need so fast your head will spin!
Cocoa Browser SN is an absolutely superlative documentation browser. It allows you to browse through the documentation rapidly and effortlessly. You just need to know one thing to use it: Foundation is the base of Cocoa; AppKit is everything for GUI apps. To figure out which framework a class is in, ask yourself if it could work in a command-line tool; if it could, it’s in Foundation.
You now have everything you need to complete this exercise. If you need some hints, check out the documentation for NSString (you want to know how to stick together your response) and for NSDate (to get and format the current date). And you’ll need to know how to get the contents of that NSTextField.
Once you’ve figured it out, explore other classes. Make a different response come up if the name is blank! Maybe make the answer come up in an NSAlert instead of that box thing! Make the color of the answer vary by the season! You get the picture.
Lesson Four: Learning a Bit More about Cocoa
Okay, you’ve dabbled in a bit of Cocoa now, but you need a better grounding in the architecture to continue. Here are some more important pieces of documentation:
Reading 4.01: “The Cocoa Frameworks” at Apple
No, you don’t at all need to remember those lists of capabilities. This will just give you some idea of what Cocoa can do for you, if you let it. Let the lists seep into your brain so that next time you come across a problem, you’ll remember that Cocoa is your guardian angel.
Reading 4.02: “Using a Cocoa Framework” at Apple
There are a lot of conventions the frameworks will use. If you can catch on to how things work, you’ll be able to guess method names (or at least enough of them to use Xcode’s autocompletion: ⌥-⎋) and design your own classes to work the same way. Remember, we’re building your Cocoa intuition. But more on making your own systems later.
Reading 4.03: “Arrays: Ordered Collections of Objects” at Apple
Reading 4.04: “Dictionaries: Collections of Keys and Values” at Apple
These core value classes are really important; you’re going to be using them all the time in your work. Make sure you can do all the basic operations with them.
Lesson Five: Becoming a Magician
Now, we’re going to get into the magic. This is the stuff that makes Cocoa worth learning, but it’s also the hardest to get a real understanding of. This is a long lesson. Read on, but pay attention. It’s important that while all this may seem like magic, you have a firm grasp of what’s going on.
Reading 5.01: “Intro to Bindings” at Cocoa Dev Central
Alright. That was crazy. You just did a whole heck of a lot without much code at all. It’s going to get a lot better, but you don’t have to understand everything you just read yet. I’m just giving you a taste of why you should care. Now to get a grasp of what’s going on:
Reading 5.03 “The Cocoa Controller Layer” (just the first page) at MacDevCenter
We’re introducing this crazy controller technology. But what’s all this about key-value coding and key-value observing? That’s really what makes controllers work. Let’s make sure you understand.
Reading 5.03: “What is Key-Value Coding?” at Apple
Reading 5.04: “Key-Value Coding Fundamentals” at Apple
Key-value coding really isn’t that complicated. The main points you’ve got to get out of it are key paths, which drive everything, and the conventions for method names: you access key with -key, and you set it with -setKey:.
Reading 5.05: “What is Key-Value Observing?” at Apple
Reading 5.09: “Registering for Key-Value Observing” at Apple
Reading 5.10: “Automatic Versus Manual Support” at Apple
Now, nothing in these articles is actually being used in the tutorial you read in the start of this tutorial, but the controller classes are using this to really take all the work away from you.
Stop for a moment and think about how this technology can be used. Say you’ve got a thread in the background checking for new posts on a blog. When that new post is retrieved, your list of posts will display it with no extra code because it uses KVO.
You’ve learned about the architecture that makes cocoa bindings work; now you’re ready to read about the bindings themselves. You’ve grown so much! I think you’re ready for the full text of this document, not just bits and pieces. Read carefully; it’s chock full of examples.
Reading 5.11: “Cocoa Bindings Programming Topics“
Lesson Six: Stepping Off the Plank Again
Alright. It’s time for you to venture off on your own again. Download the To Dos Example (by Malcolm Crawford). Compile it. Run it. Now put the code away. Make this app completely on your own, except for the loading and saving. You’ll learn about document-based applications later.
You don’t have to do the colorings for overdue dates and priorities either, but I encourage you to read Malcolm’s code to see how it’s done afterwards. If you get stuck, look at the example, but try to go on your own as much as possible. Try to find documentation for what you want to do before learning by example.
Now that you’ve got this working, again, make it your own. Add new features. Experiment. Bask in what you’ve learned.
Lesson Seven: It Just Keeps Getting Better
Alright, it’s time to introduce you to some serious magic. Bindings removed the glue code from your controller. Now it’s time to remove the code from your model. Again, pay attention, because it’s easy for this to seem like magic.
Reading 7.01: “Build a Core Data Application” at Cocoa Dev Central
You just built a journaling application without a single line of code. This is the power of Cocoa Bindings and Core Data. We’ll figure out how all of it works, but I want you to go through one more tutorial first. This one’s goes quite a lot further, and it’ll give you an intro to copy and paste. You can gloss over the localization and metadata sections for now.
Reading 7.02: “NSPersistentDocument Core Data Tutorial“
I think you’re beginning to get the picture. Now let’s understand how it all works with some documentation.
Reading 7.03: “Core Data Class Overview” at Cocoa Dev Central
Reading 7.04: “Managed Object Models” at Apple
Reading 7.05: “Managed Objects” at Apple
Reading 7.06: “Creating and Deleting Managed Objects” at Apple
Reading 7.07: “Fetching Managed Objects” at Apple
Reading 7.08: “Using Managed Objects” at Apple
Lesson Eight: More Background
There are a few more things you need to know. Let’s start with the most basic of them: how to extend something in Cocoa.
Reading 8.01: “Adding Behavior to a Cocoa Program” at Apple
Who knows? You might have to make a text field draw with a black background someday. But hey. You don’t know how to do that. It’s pretty important to understand how to draw in Cocoa, because you’ll inevitably want to make some custom interface.
Reading 8.02: “Cocoa Graphics with Quartz” at Cocoa Dev Central
Reading 8.03: “Cocoa Graphics with Quartz II” at Cocoa Dev Central
Document-based applications are very common. Fortunately, Cocoa will do most of the work for you, if you know how to leverage it.
Reading 8.04: “Document-Based Applications” at Apple
Almost through now. You’ve just got to understand how memory management works in Cocoa. In Leopard, you’ll have the option of just using garbage collection, but until then, Cocoa uses a technique called reference counting to keep track of whether an object is still important. They can be pretty confusing, so read carefully.
Reading 8.05: “Object Ownership and Disposal” at Apple
Reading 8.06: “Practical Memory Management” at Apple
Reading 8.07: “Rules for memory management in Cocoa” by Malcolm Crawford
One more thing. I’m an interface zealot. You’ll rapidly learn that it’s very difficult to actually make interfaces look just like Apple’s with the tools in Interface Builder, and the guidelines seem to be changing constantly, but the core principles in the Human Interface Guidelines still hold. Read it well.
Reading 8.08: “Human Interface Guidelines” at Apple
Lesson Nine: Fly! Be Free!
Hopefully you’ve developed some intuition now for how things work in Cocoa. Your job now is to pick a project. More specifically, to pick a small project. Something you can accomplish in a few weeks. Go too small, and you won’t learn anything; go too large, and you’ll get frustrated and give up.
Choose wisely.
Now then, before I send you along your way, I’d like to give you a few tools to aid your Cocoa intuition. Here’s where you go when you need to find answers:
- CocoaDev: a wiki that often does an excellent job summarizing Apple’s very verbose documentation.
- Cocoa Builder: a searchable index of the cocoa-dev mailing list at Apple.
- Apple’s Cocoa Programming Guides: Much more readable than raw documentation, these will summarize key concepts for you.
- Apple’s Reference: Last resort. This has everything you need, though.
I hope all this has been useful to you. If you get all the way to lesson nine and make a project, please share it in the comments! And if you have any suggestions for changes or additions, I encourage you to share those as well.









The Conversation {19 comments}
Andy, some pngs are missing. Cheers.
Whoa! The formatting on this one got all messed up. Thanks for pointing that out, David.
No problem. And thanks for the tutorial/primer. As someone moving his codebase over to Cocoa, is indeed tricky at times to see the “big picture” of Cocoa and to work out how things fit together.
Another problem is how far Cocoa has come since many of the current round of textbooks were written. Although Aaron Hillegass has said he’s hard at work on 2.0 of the bible.
p.s. The drop shadows on those windows in the pngs look quite pronounced. I take it this is the standard in Leopard?
No shh of course not I would never post Leopard screenshots.
They don’t look that weird in real usage—I like them, actually—they’re just very pronounced over a white background.
Hello Andy,
Thank you for this great mashup of getting started resources in cocoa.
On my way to lesson three now
Beetween, congratulations on starting blogging again. Honestly this is my first time reading your blog but i found some great reading material for the feature.
Also i really like the (new) design (didn’ t know the old), black alternative for night reading would be good also
Keep blogging.
A.
This article is a great resource. Sometimes Cocoa information seems like it is scattered across the known universe: a little bit here, a little bit there.
When can we expect the book version?
David Wareing said that Aaron Hillegass is working on a new version of the bible that’ll incorporate all the new technology, so hopefully that will suffice.
I may post more introductory articles once Leopard comes out—lots will change with IB and debugging and all, and all the current materials will be quite obsolete.
Also, you know, if anyone wants to hire me as a private Cocoa tutor, I’m available.
Wow! It’s about time! Thank you!!!!!! I’ve been so frustrated with the lack of info on newish features… and the delay on the release of Leopard which is holding up the release of new books.
Peace
Mike Gregoire
First, thank you for the references to the ToDos example and the memory management article, I’m glad they’re found to be useful.
I’d suggest a few modifications, re-orderings, and caveats.
Lesson 4 needs to be significantly longer (or a new lesson inserted afterward). It would be especially useful to include:
(a) An example illustrating delegation. Delegation is an important design pattern that is not as common elsewhere, and it’s easy for newcomers to overlook (or get confused by the listing of delegate methods in the class documentation). For developers coming from other platforms, it’s especially important to show why subclassing is not always the Right Thing to do (customising window closing behaviour is probably the canonical example here).
(b) An example that uses a table view to display a collection. This reinforces the idea of delegation, and provides a useful lead-in to the model-view-controller design pattern. Moreover, it also provides a vehicle to introduce key-value coding in a practical but “constrained” way, prior to the full “expanse” of bindings.
Memory management should at least be introduced earlier. The fundamental rules are very simple (http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html) and should be made clear early on to avoid confusion.
In order to make sense of the Persistent Document tutorial, the document architecture needs to be introduced earlier then Reading 8.0.4. More than just that, though, the document architecture is another “Cocoa fundamental” and getting to grips with it will help developers understand from a practical perspective other parts of the Cocoa architecture (it can help to illustrate, for example, File’s Owner and the responder chain).
Core Data: You should go through the Low-Level tutorial before the Persistent Document tutorial. It’s specifically intended to cover the fundamentals of Core Data without the distraction of the document architecture and in particular Cocoa bindings.
It would also be useful to give an idea of the length of time this process should take. An additional reason for suggesting the insertion of (much) more material at around Lesson 4 is that it is useful — typically vital — to gain adequate experience in the fundamental idioms etc. that underpin Cocoa before progressing to more abstract features of the technology. I would recommend using Cocoa for at least a couple of weeks before starting with bindings and Core Data…
mmalc
This is great! I’ve been programming for a while but I’m new to the Mac. Objective-C and Cocoa really haven’t clicked for me yet. I’ve been through some fairly simple tutorials and they all seem to do things very differently. This looks like a very good, structured way to find my footing and really understand what’s going on. Thanks!
Excellent point on the delegates, mmalc, and I agree that memory management should be introduced earlier, with perhaps more depth later. I tried to avoid giving tasks that would require tricky memory management.
The table view example is actually covered at the beginning of the Cocoa Bindings tutorial at CDC to show how much code can be saved by using bindings.
I’m not sure about the low-level tutorial: while parts of it would help the reader get a better understanding of the underpinnings, it’s really dry due to the huge amounts of code for each task. Maybe an extra credit?
I do think I’ll put some part of the document-based application in lesson 4, though, and some mention of taking a while to do all this would be good.
I guess I’m not trying to teach the reader, per-se. I’m half trying to get them excited enough about the technology to explore the documentation and half trying to give them an intuition for where to go to find answers they need. Hopefully it does at least that passably.
Thanks a lot for your feedback, Malcolm; I’ll update it as soon as I get a chance.
I’m glad you like the stuff at Cocoa Dev Central. Thanks.
Great stuff! Keep it up!
Regards,
b0bben
Greetings from Russia

Keep it up.
Waiting for good lessons
The document browser Cocoa Browser SN - is this still working. I tried using it but could not get it to work. I think it is not indexing the documentation correctly. I started using AppKiDo instead. Past the Mad Scientist lesson…still chugging along.
I had to change some things to make it work in Leopard, but it works on my Tiger machine just fine.
This was great. I’m a professional developer with experience in c, c++, c#, java, et al. and was having a hard time picking up objective-c and cocoa due to the odd syntax, massive framework and dry Apple articles. I made it through this page in a couple of two hour sessions and it really helped make the language and framework appear to be manageable. Great work on that. The order of articles was spot on and you did a great job of building each step on previous knowledge.
The only place I deviated was in the memory management section. Being familiar with both managed and unmanaged memory systems, I was intrigued by the o-c system, so I skipped ahead an read that bit pretty early =)
Thank you for putting all of this together!
Hey Andy,
Thanks for the time and effort expended to put this great reference together. I’ve been searching through the vast amount of information available to filter in just the immediately relevant tutorials for Xcode 3 and Obj-C 2. Your study plan reference a lot of current or recently updated items which helps a lot.
It’s amazing how fast the comments dropped off after October, and yet this aid will be useful for quite some time to come. I’m just getting started pulling the cobwebs off my old C and Unix programming skills to dive into Obj-C and Cocoa. If I stay on track, I’ll report back my success…!!! Wish me luck…
Great article. Thx. I believe it`s time to play with.
A good “job” 4my hacktintosh! Please inform your reader about django! ruby is out
4me
Leave a Comment
You can follow any responses to this entry via its RSS comments feed.