0
私のUITableViewControllerでは、DataSourceの外部クラスを設定しました。以下のようにUITableViewDataSourceからUITableViewCellのデリゲートを設定するにはどうすればよいですか?
class HomeViewDataSource: NSObject, UITableViewDataSource {
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(myCellIdentifier, forIndexPath: indexPath)
cell.delegate = //Should I set this to the view controller?
return cell
}
}
ご覧のとおり、デリゲートを設定したい再利用可能なセルがあります。セルには、UITableViewControllerでイベントをトリガーするボタンがあります。今のところ、ネットワークの呼び出しを実行できるように、セルのデリゲートを自分のUITableViewControllerに設定しました。私は正しいMVC形式でこれをやっているとは思わない。
UITableViewControllerのネットワーク呼び出しでは、UITableViewDataSourceの配列のプロパティが使用されます。
これを行うにはどのような方法が便利ですか?