Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法覆盖消息转发的那几个方法? #858

Open
liangdahong opened this issue Dec 28, 2019 · 0 comments
Open

无法覆盖消息转发的那几个方法? #858

liangdahong opened this issue Dec 28, 2019 · 0 comments

Comments

@liangdahong
Copy link

liangdahong commented Dec 28, 2019

是否无法覆盖消息转发的方法?如下几个,主要是为了 处理服务器返回 null 的问题处理,在消息转发阶段防止崩溃。

- (id)forwardingTargetForSelector:(SEL)aSelector;
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector;
- (void)forwardInvocation:(NSInvocation *)invocation;

JS 如下,只是模拟。

defineClass("NSNull", {
    forwardingTargetForSelector: function(aSelector) {
        return {};
    }
}, {});

可以覆盖成功,但是 null 发送消息的时候会导致无限循环调用,最后报野指针错误。

image

感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant