Domanda

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?

È stato utile?

Soluzione

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;

Altri suggerimenti

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> 
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top