How to learn Cocoa
This is something any experienced Cocoa developer has been asked at least half a dozen times:
"What’s the best way to learn Objective-C/Cocoa?"
I have two answers to this question:
- Be curious
- Don’t be satisfied
Curiosity is the heart of learning anything. If you can cultivate a deep curiosity about the Objective-C language and the Cocoa frameworks, then I guarantee that you will have absolutely no problem learning them. I’m not talking about the “oh, wouldn’t it be nice to know how to write iOS apps” kind of curiosity. I’m talking about the “why does the
@ sign go there? What’s up with these asterisks all over the place? Why are things done in this order instead of that order” kind of curiosity. Gaining this level of curiosity can be very difficult, especially at first. But without it, you’ll never really understand how everything is working together.
If you’re familiar with an sort of object-oriented programming language, then Objective-C, as a language, shouldn’t be that hard to pick up. Just use get used to the square brackets, and things will look pretty familiar. Learning the frameworks, on the other hand, will take a lifetime. The Cocoa Frameworks (Foundation, AppKit/UIKit, CoreData, CoreFoundation, MapKit, QuickLook, MediaAccess, CoreLocation, etc) are enormously broad. The Foundation framework itself is composed of 173 public classes and 31 protocols. That’s a lot of pre-built code, and that’s just one framework out of a couple dozen! There are some classes you will come to know very intimately (
NSDictionary), but even they will surprise you every now and then. Plus, Apple actively develops these frameworks; they’re being improved and optimized and expanded all the time. There will always be more to learn.
Along with the capabilities of the classes, there are patterns to learn. Design patterns describe how classes interact with each other. Some of the first ones you’ll encounter are Model View Controller, Delegation, and Class Clusters. There are many others, and they’re in there for a very good reason. As you come across them, take the time to understand why they’re there.
Do the same with the classes in the frameworks. Explore them. Play with them. Abuse them. Ask yourself:
- What problem does this solve?
- How does it solve the problem?
- Can you use these abilities for anything else?
- How would you implement this class if you had to? (And then go do it!)
Don’t Be Satisfied
As you learn Cocoa, the code you write will be terrible. Understand that. But don’t accept it. There is always a different way you could do something, and quite often one of those different ways is a better way. Always seek out opportunities to improve your code and to find different and better ways to organize it. Sometimes this will mean rewriting things half a dozen times. But you know what? That’s OK! All developers experience this. If you can learn to not be satisfied with your code, you’ll quickly learn how to iterate over it and make improvements here, tweak some stuff there, maybe rip out some layer of control and totally reorganize it… This is what programming is all about. Don’t be satisfied with how your code looks. Strive to make it a work of art and a thing of beauty.
So there you have it! These are my recommendations for how to learn Cocoa. They have served me well, and I think they pretty much summarize what I’ve observed about experienced developers.
Oh, and by the way…
- Know what a pointer is.
- Memorize the memory management rules.
- Never invoke
Welcome to Cocoa.
- markholyoake-photography likes this
- alex-the-jewellery likes this
- wrightph likes this
- creativecommonsmastersweet reblogged this from funwithobjc
- sathyame likes this
- jacknutting reblogged this from funwithobjc
- artoflivingrealty reblogged this from funwithobjc
- casque-monster-beat reblogged this from funwithobjc
- thomas-1984 reblogged this from funwithobjc
- bellimbusto2 reblogged this from funwithobjc
- first-grade-reading reblogged this from funwithobjc
- horaceho likes this
- white-curtains reblogged this from funwithobjc
- candles-holders reblogged this from funwithobjc
- floor-pillow reblogged this from funwithobjc
- grill-grates reblogged this from funwithobjc
- mixer-blender reblogged this from funwithobjc
- cricket-franchise reblogged this from funwithobjc
- cricket-master-dealer-chicago reblogged this from funwithobjc
- boynton-beach-real-estate reblogged this from funwithobjc
- 1weddingfashion reblogged this from funwithobjc
- comohacercrecerelpene reblogged this from funwithobjc
- hot-to-seo reblogged this from funwithobjc
- bug-repellent reblogged this from funwithobjc
- quick-foods reblogged this from funwithobjc
- soda-drinks reblogged this from funwithobjc
- asvab-test reblogged this from funwithobjc
- funwithobjc posted this