Getting null value exception when using in Appdelegate's didFinishLaunchingWithOptions
zayantharani opened this issue · 2 comments
Below is the code:
@assembled private var dbManager: DBInterface
override init() {
AssemblyHolder.defaultAssemblyType = ApplicationAssembly.self
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
print(appSettingsManager.getAppCenterKey())
AppCenter.start(withAppSecret: Bundle.main.object(forInfoDictionaryKey: "app_center_key") as? String, services:[
Analytics.self,
Crashes.self
])
return false
}
And by using this, I am getting an exception at Assembled.swift's wrappedValue get
Really sorry @zayantharani but I didn't see your issue until today, otherwise I would've responded sooner.
You're likely facing #2. The solution is to make sure you're declaring that you want DBInterface
to be injectable by type or by key (at least one of the two), like this:
public override func makeBindings() {
makeInjectable(dbInterface, byType: DbInterface.self)
^-- The first side of the argument is a reference to the function that builds dbInterface (whatever you've named it). Note that we're providing a reference to a function, not calling it.
Can you please confirm this is the error. If so, I'll happily take a pull request.
I'll add more features to Pilgrim soon - been very busy over last weeks.
Thank you for the reply. Actually I didn't make main.swift and was using AssemblyHolder.defaultAssemblyType = ApplicationAssembly.self in Appdelegate's init.
I realised this issue by having a look at the sample application