O'Reilly logo

Beginning Mac OS® X Programming by Drew McCormack, Michael Trent

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.1. Object-Oriented Programming

Before you begin to learn Objective-C, you need to know a little bit about what it was designed to achieve. Object-oriented programming (OOP) has really caught on only over the last 15 years or so, but is now the de facto standard for all programming languages. Nearly all development these days takes place in the object-oriented style—even in non-OO languages like C!

So what is OOP? The main distinction between programming in an object-oriented language like Objective-C, and programming in a procedural language like C, is that data and functions that operate on that data are grouped together into entities called objects. An object has both data and behavior: the data are the variables belonging to the object, and the behavior is defined by the object's functions.

An object is actually a variable or instance of a particular class. A class defines what data and functions a particular type of object has. For example, a class called Person could declare that Person objects have a name and address, and that they have functions to create a new Person, delete an existing Person, and perform operations like changing a Person's address.

If you worked through the chapter on C programming, you realize by now that OOP has many similarities with the structured programming example you encountered in the simple address book program MyAddressBook. Indeed, structured programming with Abstract Data Types (ADTs) was a forerunner of OOP, and is still used today to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required