0
我試圖想出一種方法來減少用於依賴注入的樣板代碼Cleanse到ViewController
s。但是,絕對卡在Cleanse.Component
樣板文件的類型擦除類中。我究竟做錯了什麼?斯威夫特找不到方法保證的方法
(包括代碼,以及快照的XCode,您的閱讀方便)
import Foundation
import Cleanse
protocol CleanseInjectable {
func inject(args: Any...) -> Void
func prepare() -> Void
}
extension CleanseInjectable {
func inject(args: Any...) -> Void {
}
}
class AnyCleansePropertyInjectionComponent<TargetType: AnyObject, CleanseInjectable>: Cleanse.Component {
typealias Root = PropertyInjector<TargetType>
func configure<B : Binder>(binder binder: B) {
binder
.bindPropertyInjectionOf(TargetType.self)
.to(injector: (TargetType.self as! CleanseInjectable.Type).inject)
}
}
我得到的錯誤是因爲任何斯威夫特協議的錯誤,這只是明顯的在事後離奇:Type 'CleanseInjectable' has no member 'inject'
?!
這對Cleanse開發人員來說不是問題嗎? – matt
@matt提出了一個新的標籤以防萬一 - 但是'CleanseInjectable'是我的協議(不是框架的)!看來Swift無法找到我在協議中保證的方法簽名 – Angad
我的意思是,你不應該通過github上的Issues頁面來查詢嗎?這個東西是一個總測試版,不是嗎? – matt