Encapsulation (motivation)

C structures and typedefs already provide this functionality. Hypothetical example:

typedef struct {
	double freq;	
	int keyNum; 	
} Note;	

This struct Note is now a convenient package. To create a new Note, you just call malloc.

Note *myNote1;	
myNote1 = malloc(sizeof(Note));	
myNote1->freq = 440.0;
myNote1->keyNum = 69; 	
play(myNote1);	
    

But C structs only go half way. Objective-C introduces the notion of a "Class" that encapsulates both the data and the functions that operate on them. This serves to protect the data and localize specialized knowledge of the data, making it harder to introduce bad bugs.