What are classes, objects, and methods in Objective-C?
Updated Feb 20, 2026
Short answer
Classes are blueprints that define the structure and behavior of objects in Objective-C. An object is an instance of a class, and a method is a function that belongs to a class and defines what an object (or the class itself) can do. Together, these three concepts form the foundation of object-oriented programming in Objective-C.
Deep explanation
Objective-C is an object-oriented programming (OOP) language. Instead of writing programs as a collection of unrelated functions, Objective-C organizes code into classes, objects, and methods.
==Remember this interview shortcut: Class = Blueprint, Object = Instance, Method = Behavior.==
What is a Class?
A class is a blueprint or template used to create objects. It describes:
- The properties (data) an object stores.
- The methods (actions) an object can perform.
- The common characteristics shared by all objects of that type.
Think of a class as an architectural drawing for a house. The blueprint itself is not a real house—it only describes how every house should be built.
For example, a Car class may contain:
colorspeedbrand
and methods such as:
startEnginedrivestop
What is an Object?
An object is a real instance created from a class.
Every object:
- Has its own copy of the class's properties.
- Shares the same method implementations defined by the class.
- Can behave differently because its property values may differ.
For example:
| Class | Objects |
|---|---|
Car | Red Car, Blue Car, Black Car |
Although all three cars come from the same class, each object has its own color and speed.
Every object has its own state, but all objects of the same class share the same behavior.
What is a Method?
A method is a function that belongs to a class.
Methods define what an object can do.
Objective-C has two kinds of methods.
| Type | Symbol | Called On | Example |
|---|---|---|---|
| Instance Method | - | Object | - (void)drive; |
| Class Method | + | Class | + (Car *)newCar; |
Instance methods
These operate on a particular object.
[myCar drive];Class methods
These are called directly on the class.
Car *myCar = [Car new];They are commonly used to create objects or perform utility operations.
How Classes, Objects, and Methods Work Together
The typical flow is:
- Define a class.
- Create an object from that class.
- Call methods on the object.
- The object's state changes.
Example
@interface Car : NSObject
@property(nonatomic, strong) NSString *color;
- (void)drive;
@end@implementation Car
- (void)drive { NSLog(@"%@ car is driving.", self.color);}
@endCar *myCar = [[Car alloc] init];
myCar.color = @"Red";
[myCar drive];Output:
Red car is driving.Here:
Caris the class.myCaris the object.driveis an instance method.coloris a property.
💡 A simple interview rule: A class describes what something is, an object represents a real thing, and methods describe what that thing can do.
Message Passing in Objective-C
Unlike many languages that call methods directly, Objective-C uses message passing.
[myCar drive];This means:
- Send the message
drive. - The Objective-C runtime looks for the corresponding method.
- The method is executed.
Objective-C objects communicate by sending messages rather than calling functions directly.
Real-world example
Imagine you're developing a food delivery application.
You define a DeliveryDriver class.
Every driver who signs up becomes an object.
Each driver has different information:
- Name
- Vehicle
- Rating
However, every driver can perform the same actions:
- Accept an order
- Deliver food
- Complete delivery
DeliveryDriver *driver = [[DeliveryDriver alloc] init];
driver.name = @"Alice";
[driver acceptOrder];One class can create many independent objects, each with its own data while sharing the same methods.
Common mistakes
- * **Confusing classes and objects** — A class is only a blueprint
- it does not store individual data until an object is created.
- * **Calling an instance method on a class** — Instance methods require an object. Use class methods only on the class itself.
- * **Assuming all objects share property values** — Objects share method definitions, but every object stores its own property values.
- * **Ignoring message passing** — Objective-C sends messages (`[object method]`) instead of using traditional function-call syntax.
- * **Thinking properties are methods** — Properties store data, while methods define behavior.
Follow-up questions
- What is the difference between a class and an object?
- What is the difference between instance methods and class methods?
- Why does Objective-C use message passing?
- What is the role of NSObject?