協(xié)議泛型約束
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方法泛型約束