Home > Articles > Programming > General Programming/Other Languages

Classes, Objects, and Methods in Objective-C

  • Print
  • + Share This
Learn the key concepts in object-oriented programming, so you can start working with classes in Objective-C. In this sample chapter from Programming in Objective-C, you'll learn a little bit of terminology, and then put the theory to work.
This chapter is from the book

This chapter is from the book

In this chapter you learn about some key concepts in object-oriented programming and start working with classes in Objective-C. You'll need to learn a little bit of terminology, and we'll keep it fairly informal. We'll also cover only some of the basic terms here because you can easily get overwhelmed. Refer to Appendix A, "Glossary," at the end of this book for more precise definitions of these terms.

What Is an Object, Anyway?

An object is a thing. Think about object-oriented programming as a thing and something you want to do to that thing. This is in contrast to a programming language such as C, known as a procedural programming language. In C, you typically think about what you want to do first and then you worry about the objects...almost the opposite from object-orientation.

Let's take an example from everyday life. Let's assume you own a car, which is obviously an object, and one that you own. You don't have just any car; you have a particular car that was manufactured in a factory, maybe in Detroit, maybe in Japan, or maybe someplace else. Your car has a vehicle identification number (VIN), which uniquely identifies that car.

In object-oriented parlance, your car is an instance of a car. And continuing with the terminology, car is the name of the class from which this instance was created. So, each time a new car is manufactured, a new instance from the class of cars is created, and each instance of the car is referred to as an object.

Your car might be silver, have a black interior, and be a convertible or hardtop, and so on. Additionally, you perform certain actions with your car. For example, you drive your car, fill it with gas, (hopefully) wash it, take it in for service, and so on. This is depicted in Table 3.1.

Table 3.1 Actions on Objects


What You Do with It

Your car

Drive it


Fill it with gas


Wash it


Service it

The actions listed in Table 3.1 can be done with you car, and they can also be done with other cars as well. For example, your sister drives her car, washes it, fills it with gas, and so on.

  • + Share This
  • 🔖 Save To Your Account