ViewController, :
override weak var delegate: UITextFieldDelegate? {
didSet {
if delegate?.isKindOfClass(YourTextField) == false {
textFieldDelegate = delegate
delegate = self
}
}
}
private weak var textFieldDelegate: UITextFieldDelegate?
class YourTextField: UITextField, UITextFieldDelegate {
init(){
super.init(frame: CGRectZero)
self.delegate = self
}
func textFieldDidBeginEditing(textField: UITextField) {
textField.performSelector(Selector("selectAll:"), withObject: textField)
textFieldDelegate?.textFieldDidBeginEditing?(textField)
}
}
, , , UITextFieldDelegate .
let yourTextField = YourTextField()
yourTextField.delegate = self