If you don’t specify a delegate, is the self the default delegate?
Also, if you have a UITextField do you need to make sure it’s knows it is a UITextFieldDelegate or is it one by default?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Of what object? It is up to the implementation of the specific object to decide.
No, in the absence of any other information, the delegate would probably be nil.
However, if you were writing a class implementation, and wanted the object to set its delegate to
selfby default, you could certainly do that. I think this would usually be more confusing than useful, though.If you want to do something by default, just check if the delegate is nil. (Somebody could always set your delegate to be nil, so you have to do that check anyway.)
UITextFielddoes not implement any of the methods inUITextFieldDelegate— or at least it doesn’t advertise that it does so — so I’m not sure what you mean here. AUITextFieldby itself cannot function as aUITextFieldDelegate.If you were to subclass
UITextFieldand add methods in theUITextFieldDelegateprotocol, then you could mark it as implementingUITextFieldDelegate:But that doesn’t happen by default, you have to make it happen.