Pergunta

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?

Foi útil?

Solução

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;

Outras dicas

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> 
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top