Classes and Objects

Objects are the heart of object-oriented programming. You define objects by building classes, which act as object creation templates. In Objective-C, a class definition specifies how to build new objects that belong to the class. To create a car object, for example, you define the Car class and then use that class to create new objects on demand. As in C, implementing a class in Objective-C is done in two places: a header file and implementation file. The header file specifies how the outside world can interact with the class: the instance variables and their types, and the methods with their arguments and any return types. It is like a contract promising how instances of your class will interface with other objects. The implementation ...

Get Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming 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.