Cast an instance of a class to a @protocol in Objective-C
The correct way to do this is to do: if ([self.myViewController conformsToProtocol:@protocol(MyProtocol)]) { UIViewController <MyProtocol> *vc = (UIViewController <MyProtocol> *) self.myViewController; [vc protocolMethod]; } The UIViewController <MyProtocol> * type-cast translates to “vc is a UIViewController object that conforms to MyProtocol”, whereas using id <MyProtocol> translates to “vc is an object of an unknown class that … Read more