Swift,带有associatedtype的协议。如何使用这种类型的协议创建变量?

时间:2018-11-30 10:15:05

标签: swift generics protocols

我正在编写具有关联类型的协议:

   IQKeyboardManager.sharedManager().enable = true
   IQKeyboardManager.sharedManager().enableAutoToolbar = false
   IQKeyboardManager.sharedManager().shouldShowToolbarPlaceholder = false
   IQKeyboardManager.sharedManager().shouldResignOnTouchOutside = true

问题是我无法创建var委托:SliderViewDelegate? 它给我错误提示:

protocol SliderViewDelegate: class {
    associatedtype Item
    var anyProperty: Item { get set }
    func ytmSliderView(sliderView: YTMSliderView<Item>, didSelectItemAt index: Int, withView: UIView) //sliderItemTappedAnIndex

    func ytmSliderView(sliderItemURLat section: Int, item: Int) -> String?
}

如何解决这个问题?

0 个答案:

没有答案