DeclarativeHub / Bond

A Swift binding framework
MIT License
4.23k stars 361 forks source link

batchUpdate + subscript operation causes crash #655

Open killev opened 5 years ago

killev commented 5 years ago

batchUpdate causes the crashes on both UITAbleView and UICollectionView:

    func testBatchUpdates12() {
        array.batchUpdate { (array) in
            array[2] = 4
            array.remove(at: 1)
        }
    }

the crucial thing here is array[2] = 4

killev commented 5 years ago

Sorry, the subscript operator doesn't impact. The thing is that:

collectionView.performBatchUpdates

demands dataSource to be changed inside:

If the collection view's layout is not up to date before you call this method, a reload may occur. To avoid problems, you should update your data model inside the updates block or ensure the layout is updated before you call performBatchUpdates(_:completion:).

https://developer.apple.com/documentation/uikit/uicollectionview/1618045-performbatchupdates