Changeset API Edit on GitHub
Changesets are how you interact with the datasource. They allow you to “enqueue” sets of commands to be processed by the datasource.
These commands can be seen as a sentence with three parts :
- action (insert/delete/udpate for items, insert/delete for sections)
- position specifier (indexPath for items, index for sections)
- model (that will be used to compute the components)
Here is some sample code, showing how to create a changeset - As you can see changesets are a c++ structure.
Changes can also be created from
You can even get rid of the brackets around the
NSIndexPath, thanks to C++ converting constructors :
Order in which changes are applied.
The order in which commands are added to the changeset doesn't define the order in which those changes will eventually be applied to the `UICollectionView` (same for `UITableViews`).
Be wary of this fact while computing a changeset, the conventions defined in Cocoa for batch updates are as follows:
- Deletions and Updates are applied first using the current index space.
- Insertions are then applied in the post deletions index space (updates obviously won’t modify the index space).
You can consult the following section in the Apple documentation to get more information.