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

带有返回参数的方法写法有问题 #15

Open
kiss7xin opened this issue May 27, 2020 · 1 comment
Open

带有返回参数的方法写法有问题 #15

kiss7xin opened this issue May 27, 2020 · 1 comment

Comments

@kiss7xin
Copy link

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { BOOL result = NO; for (id<SHModule> module in self.modules) { if ([module respondsToSelector:_cmd]) { result = result || [module application:app openURL:url options:options]; } } return result; }

这种带有BOOL返回值的,不能直接使用
result = result || [module application:app openURL:url options:options];
这会导致如果一个模块实现了这个方法返回YES,那么他后面的模块都无法再调用这个方法。
应改为:
BOOL moduleResult = [module application:app openURL:url options:options]; result = result || moduleResult;

@lincode
Copy link
Owner

lincode commented May 28, 2020

@kiss7xin 多谢,你可以发一个 pr 修正这个问题?我可以 merge。

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

2 participants