iosswifttyphoon

Can't inject property, setter selector not found


Using Typhoon and Swift, I am setting up my project and I have this problem. I have a class TPLAddInteractor this way

class TPLAddInteractor: NSObject, TPLAddInteractorInput {

    var output: TPLAddInteractorOutput?
    var dataManager: TPLDataManagerInterface?
}

My assembly looks like this

class TPLAddAssembly: TyphoonAssembly {

    var applicationAssembly: TPLApplicationAssembly?

    dynamic func addInteractor() -> AnyObject {

        return TyphoonDefinition.withClass(TPLAddInteractor.self) {
            (definition) in

            definition.injectProperty("output", with: self.addPresenter())
            definition.injectProperty("dataManager", with: self.applicationAssembly?.dataManager())
        }
    }

    dynamic func addPresenter() -> AnyObject {

        return TyphoonDefinition.withClass(TPLAddPresenter.self) {
            (definition) in

            definition.injectProperty("interactor", with: self.addInteractor())
        }
    }
}

And then I receive this error right after running the app:

reason: 'Can't inject property 'dataManager' for object '<TPL.TPLAddInteractor: 0x7ff5b2d2bcf0>'. Setter selector not found. Make sure that property exists and writable'

I am reading the Swift example of Typhoon and I don't see anything unusual in my code. But I am new on Swift so maybe I'm missing something.

Thanks


Solution

  • To work with Typhoon, it's necessary for Swift protocols to have the '@objc' directive. This is because Typhoon uses the Objective-C runtime as Swift has no native dynamism as yet.

    This requirement is documented in the Swift Quick Start.