views:

46

answers:

2

I have a front-view and a flip-view much like the utility weather-app.

To avoid dealing with the complexities of protocols... on my flipView I need to call some code that resides back on my front-view. This works... but generates a warning during compile.

[self.parentViewController returningFromGetStringView];

Warnings (shows twice):

'UIViewController' may not respond to '-returningFromGetStringView'
'UIViewController' may not respond to '-returningFromGetStringView'

The method definitely exists... and executes fine... but why the warning???

+1  A: 

The compiler tells you that it cannot verify that the receiver will handle the message (returningFromGetStringView). You could hush it by casting to id or by casting to the type of your parentViewController:

[(id)self.parentViewController returningFromGetStringView]; 

or

[(YourClassThatIsParent*)self.parentViewController returningFromGetStringView];
David
+1  A: 

The property parentViewController is declared to be a UIViewController. So, as far as the compiler knows, it's trying to send a returningFromGetStringView message to a UIViewController. Since UIViewController doesn't implement returningFromGetStringView, the compiler gives a warning.

To make the warning go away, you can cast the UIViewController to your custom class to let the compiler know which UIViewController subclass parentViewController is referring to.

[(MyViewController *)self.parentViewController returningFromGetStringView];
James Huddleston