Protocol versus Category
问题 Can anyone explain the differences between Protocols and Categories in Objective-C? When do you use one over the other? 回答1: A protocol is the same thing as an interface in Java: it's essentially a contract that says, "Any class that implements this protocol will also implement these methods." A category, on the other hand, just binds methods to a class. For example, in Cocoa , I can create a category for NSObject that will allow me to add methods to the NSObject class (and, of course, all