Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Collection/Table view changes should be sorted #684

@Adlai-Holler

Description

@Adlai-Holler

UITableView and UICollectionView allow you to make changes in any order during batch updates. When endUpdates is called, the changes are sorted and applied in a safe order. The ASDK versions don't, so if your changes (say, from an NSFetchedResultsController) aren't submitted in a specific order, you'll get an index-out-of-bounds crash sooner or later.

Here's the order changes must be applied in, so we should update ASDataController to accommodate this:

  1. Updated/reloaded items
  2. Deleted items, descending order
  3. Deleted sections, descending order
  4. Inserted sections, ascending order
  5. Inserted items, ascending order

EDIT: Oh and moves are tricky. Best bet is to break them up into delete/insert, because the fromIndexPath is pre-update while the toIndexPath is post-update. So tell the UITableView about the move whenever you want, but update the array by breaking the move into two operations that'll get sorted separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions