协议泛型约束
protocol ArrayPresenter {
associatedtype ViewType: UIScrollView
var listView: ViewType! { set get }
将listView
的类型约束在了UIScrollView
及其子类
Swift2.3方法泛型约束
func loadMore<T: UIScrollView where T: YourProtocol>(listView: T, indexPath: NSIndexPath) {
}
将listView
的类型约束在了UIScrollView
及其子类,并且遵循YourProtocol
Swift3.0.1方法泛型约束
func loadMore<T: UIScrollView>(listView: T, indexPath: NSIndexPath) where T: YourProtocol {
}
同Swift2.3方法泛型约束