2
我正在试图制作一个UITextField扩展,它在设置委托时执行其他功能。在扩展中的弱属性上添加didSet观察器
extension UITextField {
override weak public var delegate: UITextFieldDelegate? {
didSet {
print("Do stuff")
}
}
}
这失败的三个错误:
'delegate' used within its own type
'weak' cannot be applied to non-class type '<<error type>>'
Property does not override any property from its superclass
什么我需要为Do stuff
改变在委托的设置要打印的?
最终,我试图看看如何依次调用多个代表(而不是被限制为一个)。然而无论如何,观察者模式在这种情况下更强大。 –