I have a class that extends UITextfield. I also have the same class set to be it\'s own delegate so when the text field is selected I can change the background color. Once I
Subscribe to UITextFieldTextDidBeginEditingNotification
or UITextFieldTextDidEndEditingNotification
NSNotification
s. In callbacks check if notification object is self. Then perform some action on it.
The delegate is always another UIViewController
as the events are delegated to it by another class where protocol is defined.
There's no need of delegate methods in the same class when you can access all the variables and methods in the same class.
you simply can call [self someFunction]
.
As you are inheriting the UITextField , you don't need to define even a property for the UITextField delegate.You just need to set it a different viewController.
Also the class defining the protocol just has the declaration and it does not conform to the protocol.
The delegate will be the class which conforms to the protocol.
The discussion in this question should guide you in the right direction self.delegate = self; what's wrong in doing that?