Reputation: 9660
I am doing the following:
self.firstNameTextField.delegate = self.firstNameTextField;
My firstNameTextField
is a custom text field. I want the custom text field to handle all the delegate events. When I do the above I get the following warning:
Assigning to id from incompatible type
UITextField
.
What is this warning about and how can I remove it?
Upvotes: 2
Views: 1520
Reputation: 318824
Your custom UITextField
class needs to indicate that it conforms to the UITextFieldDelegate
protocol.
@interface MyCustomTextField : UITextField <UITextFieldDelegate>
Also make sure that your firstNameTextField
property is declared as:
@property (nonatomic) MyCustomTextField *firstNameTextField;
Upvotes: 5
Reputation: 1783
I think the problem is, the custom class is not conformed with UITextFieldDelegate
protocol.
You should add it to your declaration like this
@interface MyController : NSObject <UITextFieldDelegate>
Upvotes: 2