You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm trying to use sentMessage with subclass. I have a class called
classListController:UIViewController{overridefunc viewDidAppear(_ animated:Bool){
super.viewDidAppear(animated)
// THIS IS AN OVERRIDDEN METHOD
}func hello(){
// THIS IS A METHOD FROM SUBCLASS
}}
@onmyway133 Hello, I think this problem is caused difference of method invocation between Swift and Objective-C.
Actually, NSObject.rx.sentMessage and NSObject.rx.methodInvoked is based on method swizzling, Swift method invocation based v-table and it's not affected by method swizzling.
If you want to use objc_msgSend way in swift, you can use dynamic modifier on your function.
classListController:UIViewController{overridedynamicfunc viewDidAppear(_ animated:Bool){
super.viewDidAppear(animated)
// THIS IS AN OVERRIDDEN METHOD
}dynamicfunc hello(){
// THIS IS A METHOD FROM SUBCLASS
}}
But in my opinion, it's not good that using NSObject.rx.sentMessage and NSObject.rx.methodInvoked a lot.
Hi, I'm trying to use
sentMessage
with subclass. I have a class calledAnd I use
sentMessage
I see that
subscribe
is not called at all. It seems thatsentMessage
does not work for subclass ifWhat I'm trying to do is onmyway133/blog#55. I've just read this #308 so maybe there's some clues there.
I don't like swizzling, just want to see how it works with this case
The text was updated successfully, but these errors were encountered: