11. Categories, Extensions, and Security

In Chapter 6, “Classes and Objects,” you learned the basics of defining classes and allocating, initializing, and copying object instances. But there is more to life than simple object creation. This chapter shows you how to add a method to an existing class even if you don’t have the source code for that class, how to hide the existence of methods and instance variables from (at least some) prying eyes, and how to limit access to an object’s instance variables. It also discusses Objective-C security (and the lack thereof).

Categories

Categories let you add additional methods to an existing class without subclassing it, and without requiring access to the class’s source code. Using a category to extend ...

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.