Category for a class that conforms to a protocol [duplicate]
问题 This question already has answers here : Can a category implement a protocol in Objective C? (1 answer) Making class conform to protocol with category for existing methods (2 answers) Closed 6 years ago . I'm trying to implement a category for a UIViewController and I want to be certain that the object conforms to a certain protocol. Something like this: #import <UIKit/UIKit.h> @interface UIViewController<MyProtocol> (Category) @end Is this possible? 回答1: Swap category and protocol: