@@ -71,14 +71,18 @@ static void RACSwizzleForwardInvocation(Class class) {
71
71
if ([baseClass instancesRespondToSelector: aliasOfOriginalSelector]) {
72
72
// `self` uses a runtime subclass generated by third-party APIs, and RAC
73
73
// found an existing implementation for the selector at the setup time.
74
- // Call that implementation.
74
+ // Call that implementation if it is not the ObjC message forwarder .
75
75
Method xchgMethod = class_getInstanceMethod (baseClass, aliasOfOriginalSelector);
76
76
IMP impl = method_getImplementation (xchgMethod);
77
77
78
- IMP oldImpl = class_replaceMethod (baseClass, originalSelector, impl, method_getTypeEncoding (xchgMethod));
79
- invocation.selector = originalSelector;
80
- [invocation invoke ];
81
- class_replaceMethod (baseClass, originalSelector, oldImpl, method_getTypeEncoding (xchgMethod));
78
+ if (impl != _objc_msgForward) {
79
+ IMP oldImpl = class_replaceMethod (baseClass, originalSelector, impl, method_getTypeEncoding (xchgMethod));
80
+ invocation.selector = originalSelector;
81
+ [invocation invoke ];
82
+ class_replaceMethod (baseClass, originalSelector, oldImpl, method_getTypeEncoding (xchgMethod));
83
+ } else {
84
+ forward = YES ;
85
+ }
82
86
} else if ([superclass instancesRespondToSelector: originalSelector]) {
83
87
// The stated class has an implementation of the selector. Call that
84
88
// implementation if it is not the ObjC message forwarder.
0 commit comments