11. Categories, Posing, and Protocols

In this chapter you'll learn about how to add methods to a class in a modular fashion through the use of categories, how one class can substitute for another one, and how to create a standardized list of methods for others to implement.

Categories

Sometimes you might be working with a class definition and want to add some new methods to it. For example, you might decide for your Fraction class that, in addition to the add: method for adding two fractions, you'd like to have methods to subtract, multiply, and divide two fractions.

As another example, say you are working on a large programming project and as part of that project a new class is being defined containing many different methods. You have been assigned ...

Get Programming in Objective-C 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.