Articles index

Resources for learning Objective-C and AppKit

April 1 2020 by Jeff Johnson
Support this blog: StopTheMadness, Underpass, PayPal.Me

This blog post is not an April Fools joke. It addresses a serious documentation problem. There are millions of lines of Objective-C code in active use, and of course millions of Macs in active use. But how does a new developer work with them?

I became a software developer before the iPhone existed, and long before Swift existed. Back then, about 15 years ago, if you wanted to develop for the Mac, the recommended programming language was Objective-C, and the recommended application framework was AppKit, so I learned them. I would still recommend using them, if you're developing for the Mac. (The reasons why are much too long to fit in this blog post.) Since these technologies have unfortunately fallen out of favor, the resources for learning them are not as readily available as before. It appears that many would-be Mac developers don't even know where to start learning. That's where I come in, as someone who has been there before. There's no definitive way to learn, but I can offer some suggestions from my own experience.

To become a top Mac developer, you have to start at the bottom. Specifically, you have to start at the bottom of the Apple Developer Documentation, in the Documentation Archive. The cellar of apple dot com. Back when I learned Mac development, this wasn't called the documentation archive, it was just the documentation. I "taught myself" (or Apple taught me) Mac development by reading this documentation. The documents in the archive are sorted by modification date, as they always had been before they became the archive, which I found quite nice, because it was easy to see what's "new". This was especially convenient around WWDC time. You'll notice that the documentation archive has not received any updates since 2018, and many documents were last updated much earlier than that. At one time, however, before the new Apple Developer Documentation existed, when what is now the Documentation Archive was simply the documentation, these documents were the state of the art. They used to be an excellent way to learn Mac development, and though they've become somewhat outdated, they still can be an excellent way to learn Mac development. So let's dig down deep in the documentation cave and hope we strike gold!

Objective-C Resources

If you want to learn Objective-C, here are some documents that I think would be useful:

  1. The C Programming Language. This is a book, AKA K&R (Kernighan and Ritchie), not in the Apple documentation, but it's worth mentioning anyway, because Objective-C is a superset of C, and in my opinion if you want to learn Objective-C, you should learn C first. If you already know C, then great, you can skip this book (or maybe you already read it). If you don't know C, then K&R is the classic text. It's a decent starting point, and it's relatively short. When I learned Objective-C, I didn't know C, so I read K&R first. There are plenty of other books and documents that teach C, however, so K&R is just my suggestion, not your only option. In any case, I do think it helps a lot to know C before you learn Objective-C.
  2. Object-Oriented Programming with Objective-C. This is a very short introduction and overview of object-oriented programming from the perspective of Objective-C. If you're not very familiar with object-oriented programming, you'll want to start here. If you're already very familiar with OOP and have used languages such as Java, you can probably skip this document, though it's quite short regardless.
  3. The Objective-C Programming Language. This is actually an "older" document. Of course all of the Documentation Archive is older, but this document in the archive was superseded by another, later document in the archive, in fact the next item in this list. Both "The Objective-C Programming Language" and "Programming with Objective-C" are technical documents that teach you the syntax and semantics of Objective-C. The former describes an earlier version of the Objective-C language, while the latter describes a more "modern" version of Objective-C with additional features that were added later, after Xcode switched compilers from gcc to clang. So technically you could skip "The Objective-C Programming Language" and read "Programming with Objective-C" instead. In my opinion, however, it's better to begin with "The Objective-C Programming Language" and learn a version of Objective-C that was in some sense "simpler". One could argue that it was not simpler with regard to memory management, but I feel that it's important to learn "manual" memory management, to give you a deeper understanding of the language.
  4. Programming with Objective-C. This is an essential technical document for teaching you the syntax and semantics of "modern" Objective-C. You can read it after "The Objective-C Programming Language" as I would recommend, or instead of "The Objective-C Programming Language" if you're pressed for time, but you should definitely read this one. It's the most important document in the Objective-C list.
  5. Concepts in Objective-C Programming. This document places Objective-C into the context of Cocoa (AKA the AppKit and Foundation frameworks) at a conceptual level, describing the building blocks of the Cocoa Objective-C API. It's a good lead-in to learning AppKit, once you've grasped the technical details of Objective-C.

AppKit Resources

And here are some documents that I think would be useful if you want to learn AppKit:

  1. Mac Technology Overview. This is a brief document that gives a high level overview of Mac development, with a focus on the Mac operating system. The chapter "Migrating from Cocoa Touch" may be particularly interesting to iOS developers.
  2. Mac App Programming Guide. This is another brief, high level overview of Mac development, this time with a focus on application API rather than on the OS.
  3. View Programming Guide. This material may be somewhat familiar to UIKit developers, which I think makes it a good segue into AppKit development. Learn about NSView here, which is mostly the same as UIView… except when it's not!
  4. Window Programming Guide. NSWindow in AppKit roughly corresponds to UIWindow in UIKit, but windows are far more important to Mac development than to iOS development. On iPhone, there's typically only one full screen window for each app, whereas on the Mac, each app can have many differently sized and resizable windows on the screen. Study the Window Programming Guide carefully, because NSWindow is not merely a container for NSView. The entire Mac app user interface revolves around windows.
  5. Cocoa Drawing Guide. If you're accustomed to using Core Animation for everything on iOS, then you're in for a culture shock. Go old school with drawRect!
  6. Cocoa Event Handling Guide. I've saved the best for last. You don't understand how a Mac app works until you understand how it handles events, such as key presses and mouse clicks. The run loop is the heart of a Cocoa app, and event handling is one the "keys" to making an app feel native on the Mac. There are crucial differences here between Mac and iOS, so study this Mac document carefully.

Hopefully these resources are a good start, though they're not exhaustive by any means. As you read them, you'll see that they contain links to other very useful documents not mentioned above. Follow the new links that you discover as your needs and interests suggest. Mac development has nearly endless possibilities, much more so than iOS development, in my opinion. Once you've mastered the documents I've mentioned, you can choose your own Mac adventure!

Support this blog: StopTheMadness, Underpass, PayPal.Me

Articles index