Closed eeeesong closed 3 years ago
private func configureDataSource() {
self.dataSource = UITableViewDiffableDataSource.init(tableView: self.gameListTableView) {
[weak self] (tableView, indexPath, game) -> UITableViewCell in
guard let self = self else { return UITableViewCell() }
let cell = self.gameListTableView.dequeueReusableCell(withIdentifier: GameCell.reuseIdentifier) as! GameCell
self.viewModel.setCellInfo(with: game)
self.viewModel.delegate = self
cell.updateUI(with: self.viewModel)
self.bindSelection(with: cell)
return cell
}
}
class SelectViewModel {
weak var delegate: GameCellDelegate!
}
protocol GameCellDelegate: AnyObject {
func didPressButton(with gameInfo: GameInfo)
}
수정 완료!
self가 가지고 있는 요소의 delegate를 self로 지정해서 강한 참조가 발생한 게 아닐까요..? tableView의 dataSource나 delegate가
weak
으로 되어있으니 viewModel의 delegate도 weak하게 설정해주면 되는 것 같기도 하네요!!다만 메모리 그래프가 여전히 안 열려서 확인은 전혀 못해봤어요 OS 업데이트 문젠가 싶어서 업데이트 데이터 다운로드 중입니다ㅎㅎ..