Chapter 3. Object-Oriented Programming with Objective-C

Object-oriented programming isn’t rocket science, but you can’t learn it overnight either. There is a lot of terminology—composed of words like “encapsulation” and “polymorphism” and phrases like “is-a” and “has-a”—that goes with the territory. The concepts behind these terms are not terribly complicated, but they can be hard to explain. Like most useful fields of study, you must work with it a while before it all clicks together in your mind. As each concept becomes clear, you will gain a deeper understanding of the subject. That said, you don’t have to understand everything about object-oriented programming on the first pass to make good use of the concepts.

In this chapter, we present the object-oriented concepts that matter most when working with Cocoa, along with quite a bit of hands-on practice using those concepts. If this is the first time you’ve approached object-oriented programming, read carefully, but don’t worry if you don’t get everything at first. Just remember to flip back to this part of the book later if something didn’t sink in. If you already know a bit about object-oriented programming, then you should treat this as a refresher and see how Objective-C’s implementation of the object-oriented concepts with which you are familiar works.

Introducing Objects

Procedural programming divides the programming problem into two parts: data and operations on that data. Because all of the functionality of a procedural ...

Get Learning Cocoa with Objective-C, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.