I have a class instance that is created by an instance of a parent class. When the child class is created, it is given a pointer to the parent class, so that I can launch an instance method (myMethod) on the parent class from the child class.
My parent class is a UIViewController, called myViewController. However, XCode gives me a warning, saying that ‘UIViewController may not respond to myMethod’.
The line (in the child class) that causes the error looks like this:
[self.parent myMethod];
Although this follows through and works fine, I would like to prevent the warning message. Is there something I can do to reassure XCode that there is no problem, and that ‘self.parent’ (which is a UIViewController) will respond to ‘myMethod’?
you could typecast it:
…although the design is often a smell.