Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. @IBAction func insertAndDeleteButtonTapped(_ sender: Any) {
  2. collectionView.performBatchUpdates({
  3. print(collectionView.numberOfItems(inSection: 0))
  4. let index = 1
  5. for i in (index..<numbers.count).reversed() {
  6. numbers.remove(at: i)
  7. collectionView.deleteItems(at: [IndexPath(item: i, section: 0)])
  8. print(collectionView.numberOfItems(inSection: 0))
  9. }
  10. numbers.insert(100, at: index)
  11. collectionView.insertItems(at: [IndexPath(item: index, section: 0)])
  12. print(collectionView.numberOfItems(inSection: 0))
  13. }, completion: { _ in
  14. print(self.collectionView.numberOfItems(inSection: 0))
  15. })
  16. }
  17.  
  18.  
  19. //output
  20. 3
  21. 3
  22. 3
  23. 3
  24. 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement