ivlevAstef / DITranquillity

Dependency injection for iOS (Swift)
MIT License
423 stars 32 forks source link

Register with init without parameters after update to v3.7.1 #139

Closed Anavrin1990 closed 5 years ago

Anavrin1990 commented 5 years ago

This form of register doesn't work for classes with init without parameters only this form container.register{ClassName()}

image

Anavrin1990 commented 5 years ago

No, it is work for classes with init without parameters. I don't know why it is happening

Снимок экрана 2019-05-31 в 16 34 49
ivlevAstef commented 5 years ago

Please write swift version. I check tests on swift 5.0,4.2, 4.0 and it's works.

But on version 3.x it's doen't work - I wrote about it in version 3.7.0.

If swift version 4.0 and greatest please write one full test. I cann't reproduce.

ivlevAstef commented 5 years ago

I found problem. DisposeBag have more initialization method:

public override init()
public convenience init(disposing disposables: Disposable...)
public convenience init(disposing disposables: [Disposable])

And library can't decide I think your viewController have two initializations:

init(disposebag: DisposeBag)
init(nibName:bundle:)

In old realizations for one parameter registers need wrote register1 - this cut off part of the options. But now have only register.

Please use other syntax;

container.register(ViewController.init())
container.register { ViewController() }
container.register(ViewController.init(nibName:bundle:))
container.register { ViewController(nibName: $0, bundle: $1) }
container.register(ViewController.init(disposebag:))
container.register { ViewController(disposebag: $0) } 
container.register(DisposeBag.init())
container.register { DisposeBag() }
container.register(DisposeBag.init(disposing:))
container.register { DisposeBag(disposing: $0) }

to specify the initialization method exactly. or remove(or change access level to private) other initialization methods.

Anavrin1990 commented 5 years ago

Thank you This syntax doesn't work container.register(DisposeBag.init()) but This work perfect container.register { DisposeBag() }