I have developed a generic controller for sliding UIView and I manage UIViewController (and obviously subclass ) and must call a specific method (freeze) only if a subclass of UIViewController respond to this method:
-(void)freezeRootViewController
{
if([_rootViewController respondsToSelector:@selector(freeze)])
[ ((id) _rootViewController) freeze];
}
I don’t know the class of _rootViewController but I know it is a subclass of UIViewController, for this reason I have tried to cast my _rootViewController to ID, but I can’t compile:
Environment: XCode 4.5.1, iOs 4.3+ with ARC
Error: “No know instance method for selector ‘freeze'”
Note: I CAN’T force the developer to use a specific UIViewController subclass for the _rootViewController.
This seems to be a warning rather than an error – you should be able to compile your code and just ignore this diagnostic message. However, if you want to get rid of it completely, you can declare a protocol and do the cast as follows: