我在我的Swift 3应用程序中使用 Swinject .当我尝试
I am using Swinject in my Swift 3 app. When I tried
let container = Container() container.register(NetworkModeling.self) { _ in Network() }我说错了
Ambiguous reference to member 'register(_:name:factory:)'这是怎么了?
推荐答案我遇到了同样的问题,在这种情况下,我认为编译器可能会更加冗长.
I faced the same issue and i think compiler could be a bit more verbose in this case.
无论如何,我的问题就在我这边,而不是在 Swinject
Anyway, my problem was on my side, not in Swinject
检查以下内容:
NetworkModeling和Network在您的注册范围内可见(它们在同一模块中为public或internal.请记住,swift3引入了fileprivate和许多其他说明符,因此确保您的标识符对注册代码可见
NetworkModeling and Network are visible in scope of your registration (they are public, or internal in the same module. remember, that swift3 introduced fileprivate and many other specifiers, so make sure your identifiers are visible to registeting code
确保Network符合NetworkModeling. swift编译器无法看到继承,因此引发了有关Swinject工厂的模糊类型的错误
Make sure that Network conforms to NetworkModeling. Being unable to see inheritance, swift compiler raises error about ambigous types for Swinject factory
希望,这会有所帮助
更多推荐
Swinject
发布评论