在父控制器上回调方法而不显示警告消息
我有一个前视图和一个翻转视图,就像实用的天气应用程序一样。
为了避免处理协议的复杂性......在我的 FlipView 上,我需要调用一些驻留在我的前视图上的代码。这有效...但在编译过程中会生成警告。
[self.parentViewController returningFromGetStringView];
警告(显示两次):
'UIViewController' may not respond to '-returningFromGetStringView'
'UIViewController' may not respond to '-returningFromGetStringView'
该方法肯定存在...并且执行得很好...但是为什么会出现警告???
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???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编译器告诉您它无法验证接收者是否会处理该消息(returningFromGetStringView)。您可以通过强制转换为 id 或强制转换为 ParentViewController 的类型来隐藏它:
或
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:
or
属性
parentViewController
被声明为UIViewController
。因此,据编译器所知,它正在尝试将returningFromGetStringView
消息发送到UIViewController
。由于UIViewController
未实现returningFromGetStringView
,因此编译器会发出警告。要消除警告,您可以将
UIViewController
强制转换为自定义类,让编译器知道parentViewController
引用的是哪个UIViewController
子类。The property
parentViewController
is declared to be aUIViewController
. So, as far as the compiler knows, it's trying to send areturningFromGetStringView
message to aUIViewController
. SinceUIViewController
doesn't implementreturningFromGetStringView
, 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 whichUIViewController
subclassparentViewController
is referring to.