Question

Once I read in some google document about coding guidelines that every new instance of a class should go from a factory class, and I use SwiftSuspenders for it.

Now my question is, is it possible to create a new instance of an object that requires constructor parameters using SS's dependency injection?

Was it helpful?

Solution

Yes, Swiftsuspenders fully supports constructor injection.

You can either inject into a field (or a method or another constructor) requiring an instance of your class, or you can use injector.getInstance to directly query the injector for an instance that's created using the injector's mappings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top