NavigationSplitView Lists and Inspectors with Swift Data?

I am trying to build a user interface with a NavigationSplitView, with the sidebar containing a List that is broken into sections, with different sections built from objects of different classes (these being stored using swift data), as well as two items which are not in sections, which are not associated with underlying objects.

Basically the list is:

All

(type A section)
    A1
    A2

(type B section)
    B1
    B2

Other Thing

For the "All" option and each of the A and B objects, the view that is displayed in the content pain will have a list of a third class of object (another swift data "table"), giving C1, C2, etc.

The "Other Thing" selection will similarly have D1, D2, etc.

I am trying to add an inspector which will show controls based on the most recently selected item - this could be an A, B, C D, or "All" or "Other thing" - but the view in the inspector will need to show different controls and fields depending on the type of thing selected.

The problem I am running into is that I can't figure out how to track what is selected in the NavigationSplitView List.

If I try to use "selection:" on the List there is no common type that I can put in the Set<> to pull the objects - I can add dummy objects for "All" and "Other Thing" easily enough, but Swift Data seems to break if I make these child classes (the constructors won't compile if I try to call super.init()) and the "all" syntax can't be used because it requires Hashable and for some reason Swift seems convinced that "all Hashable" cannot conform to Hashable (!)

Evidently at one time NavigationLink could set a boolean binding if the selected item was active - but that was deprecated some time back, and I'm not sure how it would work with an arbitrary number of items in the list anyway?

I have been looking through the various APIs and I can't seem to find any way to solve this problem in Swift UI. I would think this would be a relatively common requirement for many types of apps?

Any ideas?

If it makes a difference, I am building from and targeting macOS 14.

NavigationSplitView Lists and Inspectors with Swift Data?
 
 
Q