Skip to content

0.4.4

Choose a tag to compare

@Mx-Iris Mx-Iris released this 19 Sep 12:28
· 3 commits to main since this release

New

NSTableViewDiffableReorderableDataSource — AppKit's NSTableViewDiffableDataSource with the data
source methods it never implemented.
The stock class answers only numberOfRowsInTableView:; the six
drag-and-drop methods and tableView:sortDescriptorsDidChange: are simply absent, so a diffable table
could not be reordered without subclassing it yourself and translating rows back into snapshot edits.
This subclass does that translation:

  • Drag-and-drop reordering through reorderingHandlers, shaped like
    NSOutlineViewDiffableDataSource's: canReorderItemHandler turns reordering on and decides per item,
    willReorderHandler / didReorderHandler receive an NSDiffableDataSourceTransaction carrying the
    snapshots before and after and one section transaction per section whose order changed. Several
    selected rows move together in row order, rows can move into another section, dropping onto a row
    inserts above it, and dropping above a section header lands at the end of the section above (or at the
    start of the first section). The commit is a real row move, not a reload: row views, the selection and
    anything else that lives on a row travel with it. animatesReorderingChanges (default YES) or the
    per-reorder shouldAnimateReorderingHandler switch the animation off without falling back to
    reloadData.
  • sortDescriptorsDidChangeHandler, called when the user clicks a column header; oldDescriptors
    is empty on the first change.
  • applySnapshotUsingReloadData: (with and without a completion), the explicit name for what
    applySnapshot:animatingDifferences:NO already does.

Only drags started by the data source's own table view are treated as reorders; every other drag answers
NSDragOperationNone, so a subclass can call super first and then accept its own pasteboard types.
Enabling reordering registers one private pasteboard type on the table view and leaves yours alone;
disabling it removes only that one. In Swift, NSTableViewDiffableReorderableDataSource<Section, Item>
has every member of AppKit's NSTableViewDiffableDataSource<Section, Item> plus the additions, so
adopting it is a type-name change; identifiers must be Hashable & Sendable. The Example app gains a
"Reorderable Table" page.

Compatibility

Added: NSTableViewDiffableReorderableDataSource, NSTableViewDiffableDataSourceReorderingHandlers.
Nothing public was removed or renamed and no type layout moved — existing binaries keep working without
recompiling; recompile only to use the new class. The minimum deployment target stays macOS 12.0.

Warning

AppKitPlus is in testing. No API or ABI stability is promised.
Any release may remove classes, change type layouts, or change protocol requirements, with no
deprecation period. Pin an exact version and read these notes before upgrading.

Installation

.package(url: "https://github.com/AppKitSupportProgram/AppKitPlus-Release", from: "0.4.4")

Artifact

Platform macOS 12.0+
Architectures arm64, arm64e, x86_64
Built with Xcode 27.0 Build version 27A266a
SHA-256 8b4399ecacb974276d76b0e6e77c419887f3bdffc338da39346effbc48f49d10