将类发送到不兼容类型的参数“id”警告?
当我编写这行代码时,我没想到我的程序会大惊小怪:
[twitterFeed setDelegate:self];
twitterFeed 是一个设置为转到 Twitter 移动网站的 UIWebView,但这不是重点。我收到错误“将“SocialView”(所在类的名称)发送到不兼容类型“id”的参数。我不知道如何修复它。有什么方法可以快速且无需重构我的代码太多了吗?
另外,值得注意的是,SocialView 是一个 UIViewController,如果这对您来说很重要的话。
I wasn't expecting my program to put up a fuss when I wrote this line of code:
[twitterFeed setDelegate:self];
twitterFeed is a UIWebView set to go to Twitter's mobile site, but that's beside the point. I'm getting the error "Sending 'SocialView (the name of the class that this is in) to parameter of incompatible type 'id'. I don't know how to fix it. Is there any way to do this quickly and without restructuring my code too much?
Also, it is worth noting that SocialView is a UIViewController, if that's at all important to you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以将
放入SocialView
界面声明中,看看是否可以修复警告:You could put
<UIWebViewDelegate>
in yourSocialView
interface declaration and see if that fixes the warning:如果您在静态方法中(带有 + ),则可以通过强制转换手动消除警告:
如果您在实例方法中(带有 - ),则应该遵循 chown 解决方案。
If you are in a static method (with a +), you can manually get ride of the warning with a cast:
If you are in an instance method (with a -), you should follow chown solution.
您可能想了解如何使用委托。
委托在 Objective-C 中如何工作?
确保您知道使用它们时要做什么。
You probably want to read up on how delegates are used.
How does a delegate work in objective-C?
Make sure you know what you do when you use them.