Swinject-对成员的含糊不清的引用 [英] Swinject - Ambiguous reference to member
问题描述
我在我的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
andNetwork
are visible in scope of your registration (they arepublic
, orinternal
in the same module. remember, that swift3 introducedfileprivate
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-对成员的含糊不清的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!