UICollectionView - insertItems(at: indexPath) not working

Viewed 3048

I have an array with some elements in it which my UICollectionView displays. I then go and fetch more elements and append it to my array. I want to then tell the UICollectionView that elements have been added to the datasource and to update the UI.

I tried this but it is not working:

// Add more data to my existing array
myArray.append(contentsOf: moreElements)
let indexPath = [IndexPath(row: myArray.count-1, section: 0)]
myCollectionView.insertItems(at: indexPath)

I get this error but I am not sure if I am doing something wrong.

EDIT: I do NOT want to use myCollectionView.reloadData()

1 Answers
Related