Question

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!

Was it helpful?

Solution

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>

OTHER TIPS

Maybe It should be UITextViewDelegate in :

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

I was getting such error because of this code:

@interface PlaceOrderController : UIViewController <     UINavigationControllerDelegate, UITextViewDelegate >

@property (weak, nonatomic) IBOutlet UITextField *dateForUserDOB;

To solve this I have used following:

@interface PlaceOrderController : UIViewController < UINavigationControllerDelegate, UITextFieldDelegate >

@property (weak, nonatomic) IBOutlet UITextField *dateForUserDOB;

Summary : use TextField not TextView

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top