foxsofter / flutter_thrio

flutter_thrio makes it easy and fast to add flutter to existing mobile applications, and provide a simple and consistent navigator APIs.
MIT License
756 stars 78 forks source link

Ambigous use of register #94

Closed fourdimspace closed 3 years ago

fourdimspace commented 4 years ago

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

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

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 commented 4 years ago

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 commented 4 years ago

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

foxsofter commented 4 years ago

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

fourdimspace commented 4 years ago

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

foxsofter commented 4 years ago

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

我试了下,不会报错