Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Crash: attempt to delete item 20 from section 0 which only contains 20 items before the update #54

Open
ageevvalentin opened this issue Nov 28, 2019 · 3 comments

Comments

@ageevvalentin
Copy link

ageevvalentin commented Nov 28, 2019

I gets crash:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete item 20 from section 0 which only contains 20 items before the update'

My changes:
First Changes
insert(0), insert(1), insert(2), insert(3), insert(4), insert(5), insert(6), insert(7), insert(8), insert(9), insert(10), insert(11), insert(12), insert(13), insert(14), insert(15), insert(16), insert(17), insert(18), insert(19)
Second Changes
insert(0), insert(1), insert(2), insert(3), insert(4), insert(5), insert(6), insert(7), insert(8), insert(9), insert(10), insert(11), insert(12), insert(13), insert(14), insert(15), insert(16), insert(17), insert(18), insert(19), update(20(was 0))
Crash!

I think changes update(20) should be update(0). Maybe collection view sees the changed items before inserted

@github-actions
Copy link

Message that will be displayed on users' first issue

@ageevvalentin
Copy link
Author

Yes, UICollectionViewUpdateItem has indexPathBeforeUpdate and indexPathAfterUpdate.
To use it with batch updates, you must use the following paths:
Insert - new index
Remove - old index
Change - old index

@harielakanti
Copy link

Yes, UICollectionViewUpdateItem has indexPathBeforeUpdate and indexPathAfterUpdate.
To use it with batch updates, you must use the following paths:
Insert - new index
Remove - old index
Change - old index

Please give some reply in detail?, with some code reference

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants