O'Reilly logo

Objective-C Quick Syntax Reference by Matthew Campbell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 19

image

Categories

Categories Defined

Categories are used to extend classes without using inheritance. When you use a category, you can add properties and methods to a class without declaring a super class.

To define a category, you need to add an interface and implementation. You can do this by adding new header and code files or you can add the categories right in the code file where you are working.

Category Example

As an example, let’s say that you want to take the Project class that you defined in Chapter 16 and add a constructor method that would initialize a new Project object and assign a name at the same time. You could add code like ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required