Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending Class to Parameter of Incompatible Type 'id<UIWebViewDelegate>' Warning?

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.

like image 583
musician137 Avatar asked Oct 12 '11 20:10

musician137


2 Answers

You could put <UIWebViewDelegate> in your SocialView interface declaration and see if that fixes the warning:

@interface SocialView : UIViewController <UIWebViewDelegate> {
...
}
like image 175
chown Avatar answered Oct 08 '22 17:10

chown


If you are in a static method (with a +), you can manually get ride of the warning with a cast:

[twitterFeed setDelegate:(id<UIWebViewDelegate>)self];

If you are in an instance method (with a -), you should follow chown solution.

like image 43
Cœur Avatar answered Oct 08 '22 15:10

Cœur