Dependency Injection in Swift using @propertyWrappers
Published in
4 min readApr 20, 2020
Dependency Injection (DI) is a technique whereby one object supplies the dependencies of another object.
Here is a very simple example. Instead of creating an instance of Repository
inside of ViewModel
,
it receives that instance from outside.
So, Dependency Injection is a very powerful technique, which helps to design a more clean, loosely coupled code, and improves the testability of our code which will result in a more scalable and maintainable application.
At this moment, it’s uncommon for iOS applications to use DI, and many iOS developers do not even know what it is and what its…