抑制 iPhone 应用程序中的 mayNotRespond 警告
我有一个带有选项卡控制器的应用程序,它显然有一定数量的选项卡。 TabController 中的每个 ViewController 共享一些信息,因此我决定将这些信息移至 AppDelegate 中,并综合 NSDictionary 中的所有内容,以便我可以访问那些使用
[[[UIApplication sharedApplication] delegate] sharedInformations];
该解决方案工作正常,我想它相当不错(我接受更好的解决方案)。显然,编译器警告我这样一个事实:[[UIApplication sharedApplication] delegate]可能不会响应方法sharedInformations,因为他没有在协议中找到该方法,但我知道它会的。
问题是:如何抑制该警告?
I have an App with a Tab Controller, which has obviously a certain number of tabs. Every ViewController in the TabController, share some informations, so I decided to move those in the AppDelegate and to synthesize everything in a NSDictionary so I can access to those using
[[[UIApplication sharedApplication] delegate] sharedInformations];
The solution works fine and I guess it's pretty good (I accept better solutions). Obviously, the compiler warns me about the fact that [[UIApplication sharedApplication] delegate] may not respond to the method sharedInformations because he didn't found the method in the protocols, but I know it will.
The question is: how do I suppress that warning?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以投射它:
或者稍微整洁一些:
你也可以将你的共享信息封装在 Singleton 类中并执行类似的操作
You could cast it:
or slightly tidier:
You could also encapsulate your shared info in a Singleton class and do something like