8. Categories, Posing, and Protocols
In this chapter, we’re going look at three features of Objective-C object-oriented programming: categories, posing, and protocols.
Categories let you extend a class by adding methods to a class—and you don’t need access to the base class’s code to do it; you can create new methods for a class without editing the class’s definition in code. That can be useful when you don’t have access to the source code for a class, or when you don’t want to change the source code, or when you want to customize a class in different ways.
To use categories, you create a new file with the interfaces for the new methods, use Objective-C syntax to indicate that you’re extending another class, and then put the implementations ...
Get Objective-C: Visual QuickStart Guide 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.