【发布时间】:2019-01-24 16:45:01
【问题描述】:
我创建了一个简单的协议,其中包含一个采用泛型参数的方法。
protocol NotifyDataSelected: class {
func notify<T>(data: T, value:T, at indexPath: IndexPath?)
}
我已经实现了如下所示的协议功能:
extension MainButtons: NotifyDataSelected {
func notify<Int>(data: Int, value: Int, at indexPath: IndexPath?) {
buttonSelection.updateTag(tag:value, for:indexPath)
}
}
updateTag 的签名是:
func updateTag(tag:Int, for indexPath:IndexPath) {
}
为什么?
这是使用 Xcode 10 和 Swift 4.2
【问题讨论】: