Chapter 5. Exploring Protocols and Categories
Objective-C provides two additional schemes for defining methods: protocols and categories. This chapter will describe both, explain how they differ, show how they are used, and present some design patterns that incorporate them.
Objective-C protocols are equivalent to Java interfaces. Protocols are employed just as interfaces are in Java, although less frequently. Objective-C programmers are more likely to use a relaxed form called an informal protocol.
Objective-C categories add methods to a class, independent of its primary class declaration (@interface
). The concept of a category may seem very foreign to a Java developer, but it's really quite simple. Categories are used to isolate or hide portions ...
Get Learn Objective-C for Java Developers 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.