DMInject is a Dependency Manager that helps you to clear your code and be more productive.
To run the example project, clone the repo, and run pod install
from the Example directory first.
import DMInject
class DMInjectionMapper: DMInjectionMapperProtocol {
var arrayReturn = [Any]()
// Use this map to add the objects, the DMInject will get by type
func initialize() {
arrayReturn.append(MyClass())
}
func getAllInjections() -> [Any] {
return arrayReturn
}
}
DMInject.main.initialize(mapper: DMInjectionMapper())
// Exemple 1: Easy way
var myclass: MyClassProtocol?
myclass << DMInject()
if let name = myclass?.getName() {
print(name)
}
// Exemple 2: Declarative way
let myClass2 = DMInject.main.getInstance(interface: MyClassProtocol.self)
if let name = myClass2?.getName() {
print(name)
}
// Example 3: Using Property Wraper
@Inject
var myClassX: MyClassProtocol?
- iOS 9.3
- XCode 11
DMInject is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'DMInject'
Narlei Moreira, [email protected]
DMInject is available under the MIT license. See the LICENSE file for more info.