6

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
musician137
  • 121
  • 1
  • 2
  • 5

3 Answers3

10

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
10

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

@interface SocialView : UIViewController <UIWebViewDelegate> {
...
}
chown
  • 51,908
  • 16
  • 134
  • 170
0

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.

Community
  • 1
  • 1
Totumus Maximus
  • 7,543
  • 6
  • 45
  • 69