7. The Class Object

In Objective-C, unlike Java or C++, classes are themselves objects. Objective-C classes are instances of a special class called Class. You can send classes messages, and they can execute methods. This chapter looks at the technical details of class objects and class methods and then takes a brief look at some examples of class methods. The last section of this chapter is an extended example where you’ll learn how to implement variables that are global to all instances of a given class.

Class Objects

Each class in an Objective-C program is represented by a single class object that contains the information that defines the class. You don’t have to do anything to instantiate class objects; the compiler creates them for you from ...

Get Learning Objective-C 2.0: A Hands-on Guide to Objective-C for Mac and iOS Developers, Second Edition 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.