you can use the objc runtime functions
#import <objc/message.h>
objc_super superstruct = {self, [UITextField class]};
objc_msgSendSuper(&superstruct, _cmd, args...);
문제
Is it possible to override a method in a subclass in such a way that when the superclass calls the method, those calls still go to the original method, but all other (external) calls to the method go to the overridden version?
Background: If I subclass a UITextField
and override the getter for delegate
, the built-in behavior of UITextField
that relies on the delegate appears to be using the backing ivar to access the delegate (and not touching the overridden getter); however, if I try the same thing with UITextView
, it seems that the internal behavior of UITextView
that relies on the delegate uses the overridden getter to access the delegate.
올바른 솔루션이 없습니다
다른 팁
you can use the objc runtime functions
#import <objc/message.h>
objc_super superstruct = {self, [UITextField class]};
objc_msgSendSuper(&superstruct, _cmd, args...);
I believe you did something wrong the second time.
You are saying that subclassing UITextView and overriding a method....affects the superclass??
Doesn't sound right at all.
I'd suggest making sure the view you used is an object of the overriden class and not of the default UITextView class.