*셀 구성할 때 마지막 셀 / 마지막 전 셀이 생성이될 때 로직실행
func collectionView(_ collectionView: UICollectionView, **cellForItemAt** indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MoreMoveCell.self,
for: indexPath) as? MoreMovieCell else { return UICollectionViewCell() }
cell.configure(data[indexPath.row])
// ✅ infinite scrolling
if indexPath.row == data.count -1 { // 마지막 셀이 생성(구성)될 때
**loadMoreMovie**() {
DispatchQueue.main.async {
collectionView.reloadData()
}
}
}
return cell
}