Warning about assigning to id<UITextFieldDelegate> when I'm conforming to the protocol

Architekt picture Architekt · Jan 13, 2014 · Viewed 9.1k times · Source

My view controller is conforming to UITextFieldDelegate, yet when I try and set the .delegate field of my text field to self, I get the warning:

"Assigning to 'id' from incompatible type 'AddReviewViewController *const __strong'"

My header file is this:

#import <UIKit/UIKit.h>

@interface AddReviewViewController : UIViewController <UITextFieldDelegate>
@property (nonatomic) int storeID;

@end

So as you can see, I have it declared to conform to the protocol. In the .m file, I have this:

@property (strong, nonatomic) IBOutlet UITextView *reviewTextView;

in the section "@interface AddReviewViewController ()"

Then, in viewDidLoad I do:

_reviewTextView.delegate = self;

That's where I get the warning. I've tried cleaning and rebuilding, and restarting XCode. Am I missing something obvious here? I'm conforming to the protocol....

EDIT: Thanks for the quick help. In my sleep deprived state I kept re-reading things and swore that's what I was doing but yup, typo. I can't mark an answer for a few minutes, but problem solved, thanks!

Answer

Segev picture Segev · Jan 13, 2014

In your header you have UITextFieldDelegate And then you declare UITextView. There's a big difference between those two.

Edit

@interface AddReviewViewController : UIViewController <UITextFieldDelegate>

to

@interface AddReviewViewController : UIViewController <UITextViewDelegate>