【发布时间】:2015-06-26 05:13:50
【问题描述】:
假设我想像这样创建TableViewDataSourceImpl 类:
class TableViewDataSourceImpl<T, U: UITableViewCell where U: ReusableCell>:NSObject, UITableViewDataSource {
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
}
}
然后 xcode 显示错误type 'TableViewDataSource<T,U>' does not conform to protocol 'UITableViewDataSource'
这是 xcode 中的错误吗?或者 swift 不能使用实现协议的泛型类?因为我要做tableView.datasource = tableViewDataSource
我知道我们不能将 swift 泛型转换为 Objective-c,但我不会在这里使用任何 Objective-c
我在 xcode 7 beta 1 中这样做
【问题讨论】: