问题
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:
@interface UIViewController (Category) <MyProtocol>
来源:https://stackoverflow.com/questions/16682342/category-for-a-class-that-conforms-to-a-protocol