Swinject-对成员的含糊不清的引用 [英] Swinject - Ambiguous reference to member

查看:92
本文介绍了Swinject-对成员的含糊不清的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的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

检查以下内容:

  1. NetworkModelingNetwork在您的注册范围内可见(它们在同一模块中为publicinternal.请记住,swift3引入了fileprivate和许多其他说明符,因此确保您的标识符对注册代码可见

  1. 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-对成员的含糊不清的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆