Swinject

编程入门 行业动态 更新时间:2024-10-05 13:20:40
本文介绍了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

检查以下内容:

  • 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

    本文发布于:2023-11-26 10:07:53,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1633659.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:Swinject

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!