This is a reproduction of a UICollectionView bug.
UICollectionView
s during unit tests, an NSInternalInconsistencyException
is thrown and the app crashes. This doesn't happen in a simulator and only happens during the unit test. This has been documented by blogger Feng-Pen Lin here and in a series of answers to a Stack Overflow question here.numberOfItems(inSection: )
before adding items to the UICollectionView
.Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (2) must be equal to the number of items contained in that section before the update (2), plus or minus the number of items inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).
This is a reproduction of a UICollectionView bug.