문제 상황

Cell의 재활용

Untitled

RxSwift와 Cell

class PhotoCell: UICollectionViewCell {
    
    // MARK: - Properites
    static let identifier = "PhotoCell"
    
    var disposeBag = DisposeBag()

		override func prepareForReuse() {
        disposeBag = DisposeBag()
    }
private func configureCardDataSource() {
        cardDatasource = UICollectionViewDiffableDataSource<LikeSection, Like>(collectionView: cardCollectionView, cellProvider: { collectionView, indexPath, item in
            guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: LikeCardCell.identifier, for: indexPath) as? LikeCardCell
            else { return UICollectionViewCell() }
    
            cell.xButton.rx.tap
                .map { Reactor.Action.didTapXButton }
                .bind(to: self.reactor.action)
                .disposed(by: cell.disposeBag)
                    
            
            cell.updateCell(item: item)
            return cell
        })

참고 자료

[iOS] RxSwift 와 UI Cell 을 함께 사용할때 생각할 것들