I want to put something like this in a method for UITextField
& UITextView
.
- (void)changeKeyboardType:(UIKeyboardType)keyboardType {
paymentTextView.keyboardType = UIKeyboardTypeAlphabet;
[paymentTextView resignFirstResponder];
[paymentTextView becomeFirstResponder];
}
How do I do this? I know I can create categories for both UITextField
& UITextView
but is it possible to do it in one shot?
By one shot, I mean add it to both classes with one protocol instead of making two categories, one for UITextView
& one for UITextField
. I've heard a protocol is similar to a Ruby module, but in a Ruby module, I can implement the method. In a protocol, it only seems that I can declare the method but not implement it. Can I also implement the method in the protocol, and then include this protocol in UITextField
& UITextView
?
How to add a method to an existing protocol in Cocoa? is close but not quite.