I need to add some methods to the delegate protocol of my custom UITextField subclass. So I put this in the header:
@protocol MyTextFieldDelegate (UITextFieldDelegate)
- (void)textfieldDi开发者_如何学PythondSomething:(UITextField*)textField;
@end
Is this fine?
In principle I think it looks fine. The only point I would make is I would write something like:
@protocol MyTextFieldDelegate (MyTextFieldDelegateExtras)
- (void)textfieldDidSomething:(UITextField*)textField;
@end
to distinguish it from the methods defined in the UITextFieldDelegate
protocol.
But really if you want to extend the protocol, then use:
@protocol MyTextFieldDelegate <UITextFieldDelegate>
- (void)textfieldDidSomething:(UITextField*)textField;
@end
also when adding categories its suggested to add it in as a separate file with the naming convention of MyTextFieldDelegate+MyTextFieldDelegateExtras.h
精彩评论