December 18, 2006
Every so often on forums or mailing lists I see someone ask the question, “how do I learn Cocoa?” There’s no short answer, and rather than try to type out a reply each time the subject is brought up, I’m going to expand on it a bit here. Even though there’s no right path for everyone, I can give some tips and advice from my own experience. Read on if you feel overwhelmed, or just don’t know where to begin.
Do the Currency Converter Tutorial
Before you write a single line of code you need to get familiar with the basic tools for programming in OSX. If you’ve never set foot in Xcode or Interface Builder, Apple’s Currency Converter tutorial is just the thing you need. It will also introduce you to those [ ] braces that seem so weird at first if you’re coming from a different language.
Learn about Memory Management
Whether you’ve dealt with memory management in other languages or not, Objective-C’s retain release pattern probably isn’t going to be familiar. It’s not something to worry about though, memory management in Objective-C is easy to learn, and works well in practice. Most tutorials are going to be roughly the same, but you can go here or here for starters.
Know your Resources
Part of programming any language is knowing where to go to get help and information. In addition to the built-in API documentation there are some great community resources out there, and I’d suggest visiting them each time you sit down to code, if not daily. A few that have been indispensable to me are Apple Developer Connection, the CocoaDev Wiki, and the Cocoabuilder Mailing List Archive.
It’s also a great idea to become active in the Cocoa developer community. In addition to providing interesting daily reading, you’re bound to pick up useful little tricks and hints that aren’t publicized elsewhere. Apple’s Cocoa-dev Mailing List, and OmniGroup’s MacOSX-Dev Mailing List are both active centers for discussion. Blogs, from both small and large development companies, are also a good source of information (although I assume if you’re reading this, you already know that). Take a look around Cocoa Blogs for starters.
If this is your first introduction to programming, you might want to read through CocoaLab’s Become an Xcoder e-book, which covers the basics using the OSX environment. Also, Cocoa Dev Central’s Tutorials are extremely helpful and well-written, for beginners and experienced programmers both.
Forget about Bindings
Maybe you’ve heard about these neat new technologies like Bindings and Core Data, and you’re thinking you don’t have to worry about things like data source methods because they’re the “old fashioned” way. Well, forget it. Bindings saves you a lot of work, but it’s no replacement for understanding how things work at a lower level. In fact, once you start writing a real world application using bindings, you’ll almost always need to use a trick or two to get them working, and that requires an intimate knowledge of key value coding and object handling. Learn the basics first, and save bindings and Core Data until they’re really needed.
Buy Hillegass’ Book
Cocoa Programming for Mac OSX is one of the best Cocoa books you can buy. Even though most programmers recommend it as the first step in learning Cocoa, I’m leaving it towards the end here. It’s not because Hillegass doesn’t teach you the basics of Cocoa programming, but because the majority of the book focuses on more advanced topics such as writing a subclass of NSView, or working with the responder chain. If you already know the fundamentals behind Cocoa and are enthusiastic about using those skills to write a real application, you’re going to get a lot more out of this book than using it as your first and only resource.
Explore the Frameworks
Believe it or not, Cocoa programming doesn’t just involve Cocoa. There is a lot of functionality hidden away /System/Library/Frameworks that isn’t included in a new Cocoa project by default. You can find everything from CD burning to working with Open GL, and they can do a lot of the heavy lifting for you. Best of all, there are no restrictive licensing issues or huge price tags involved.
Write your own Dream App
You can read as many tutorials and books as you want, but there’s simply no substitute for writing code. It doesn’t matter if your idea sucks, the code you write is terrible, or if the end result doesn’t always work correctly (assuming you finish it at all). As long as you’re working on something, you’re going to end up running into new challenges, gaining experience and learning new concepts. And in my experience, that’s simply the best way to improve your skill set, no matter what language you’re working in.