3

使用 Typhoon 和 Swift,我正在设置我的项目,但我遇到了这个问题。我这样TPLAddInteractor上课

class TPLAddInteractor: NSObject, TPLAddInteractorInput {

    var output: TPLAddInteractorOutput?
    var dataManager: TPLDataManagerInterface?
}

我的程序集看起来像这样

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())
        }
    }
}

然后我在运行应用程序后立即收到此错误:

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

我正在阅读 Typhoon 的 Swift 示例,我的代码中没有发现任何异常。但我是 Swift 的新手,所以也许我遗漏了一些东西。

谢谢

4

2 回答 2

4

要使用 Typhoon,Swift 协议必须具有“@objc”指令。这是因为 Typhoon 使用的是 Objective-C 运行时,因为 Swift 还没有原生的活力。

此要求记录在Swift Quick Start中。

于 2015-03-10T22:02:05.027 回答
1
//Inject as follows it will give a warning but its working for me:
definition?.injectProperty(Selector(("cityInfo")), with: self.coreAssembly.cityInfo())
于 2017-04-30T19:29:10.430 回答