假设我想使Class 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中的错误吗?或迅速不能使类与实现协议的泛型?因为我要制作tableView.datasource = tableViewDataSource
我知道我们无法将Swift泛型转换为Objective-C,但我不会在这里使用任何Objective-C

我在xcode 7 beta 1中执行此操作

最佳答案

只需将我的xcode更新为beta 2,它就可以工作!

09-26 19:57
查看更多