I created a super simple protocol:
protocol IndependentProtocol {}
and service:
class IndependentService: IndependentProtocol {}
and the following works Swinject:
defaultContainer.register( IndependentProtocol.self )
{
_ in IndependentService()
}
but the following:
defaultContainer.register( IndependentProtocol.self )
{
_ in IndependentService()
}.inObjectScope( .Container )
given error:
Ambiguous reference to member 'register(_:name:factory:)'
and, interestingly, the following works (i.e. services with parameters can be registered in the area .container):
defaultContainer.register( AnotherProtocol.self )
{
r in AnotherService(
signals: r.resolve( AnotherService.self )!
)
}.inObjectScope( .container )
I read this similar question which did not help: Swinject - Ambiguous link to the participant
Thanks to everyone in advance.
source
share