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

Ambigous use of register #94

Closed
fourdimspace opened this issue Oct 30, 2020 · 5 comments
Closed

Ambigous use of register #94

fourdimspace opened this issue Oct 30, 2020 · 5 comments

Comments

@fourdimspace
Copy link

fourdimspace commented Oct 30, 2020

截屏2020-10-30 上午10 11 05

如图所示,OC代码转化为相应的swift代码后,以下三个方法具有相同的方法签名

  • (void)registerModule:(ThrioModule *)module
  • (ThrioVoidCallback)registerPageObserver:(id)pageObserver
  • (ThrioVoidCallback)registerRouteObserver:(id)routeObserver;
    造成编译器无法区分要调用哪一个函数

macOS:10.15.7
XCode: Version 12.1 (12A7403)
swift: swift5
thrio:thrio: ^0.5.1

Flutter 1.20.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision fba99f6cf9 (6 weeks ago) • 2020-09-14 15:32:52 -0700
Engine • revision d1bc06f032
Tools • Dart 2.9.2

@foxsofter
Copy link
Owner

foxsofter commented Oct 30, 2020

import Foundation
import thrio

class SwiftPageObserver: NSObject, NavigatorPageObserverProtocol {
}

class SwiftRouteObserver: NSObject, NavigatorRouteObserverProtocol {
}

class SwiftModule: ThrioModule {
    override func onModuleInit() {
    }

    override func onPageRegister() {
        _ = register(SwiftPageObserver())
        _ = register(SwiftRouteObserver())
        _ = register({ (params) -> UIViewController? in
            if #available(iOS 13.0, *) {
                return UIHostingController(rootView: Page5View())
            } else {
                return UIViewController()
            }
        }, forUrl: "/biz1/swift1")
    }
}
`

@foxsofter
Copy link
Owner

这样试试,返回值要忽略的话,得 _ 下

@foxsofter foxsofter added the more-information-needed Please provide more information so we can reproduce the issue, thank you! label Nov 2, 2020
@foxsofter
Copy link
Owner

请查看main分支的Swift相关的demo

@fourdimspace
Copy link
Author

可能是我使用的问题,如果register()方法传递的参数同时继承或者实现了ThrioModule, NavigatorRouteObserverProtocol, NavigatorPageObserverProtocol 中的两个,就会有问题,否则就能编译通过

@no-response no-response bot removed the more-information-needed Please provide more information so we can reproduce the issue, thank you! label Nov 3, 2020
@foxsofter
Copy link
Owner

可能是我使用的问题,如果register()方法传递的参数同时继承或者实现了ThrioModule, NavigatorRouteObserverProtocol, NavigatorPageObserverProtocol 中的两个,就会有问题,否则就能编译通过

我试了下,不会报错

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