Effective Objective-C 2.0: 52 Specific Ways to Improve Your iOS and OS X Programs
by Matt Galloway
4. Protocols and Categories
Protocols are a language feature similar to interfaces in Java. Objective-C does not have multiple inheritance, so protocols provide a way to define a set of methods that a class should implement. Protocols are most often used in implementing the Delegate pattern (see Item 23), but there are other uses as well. Getting to know them and using them can make code a lot more maintainable, as they are a good way of documenting an interface to your code.
Categories too are an important language feature of Objective-C. They provide a mechanism for adding methods to a class without having to subclass it as you would have to in other languages. This feature is made possible by the highly dynamic nature of the runtime but also ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access