From 73fbac5708398c5c900b3c7cc1bd6ea87d626053 Mon Sep 17 00:00:00 2001 From: Addison Hanrattie <40609224+supersimple33@users.noreply.github.com> Date: Wed, 10 Sep 2025 15:32:01 +0000 Subject: [PATCH 1/4] Adding option for persistent model as sorting --- Sources/TablerSort.swift | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Sources/TablerSort.swift b/Sources/TablerSort.swift index b7a6726..aab3260 100644 --- a/Sources/TablerSort.swift +++ b/Sources/TablerSort.swift @@ -153,6 +153,40 @@ public extension View { func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + + /// Swift-data support + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } private func xlat(_ direction: TablerSort.Direction) -> SortOrder { direction == .forward ? SortOrder.forward : SortOrder.reverse From 735f102ff5cddc5ac8319085027b5844415e23f0 Mon Sep 17 00:00:00 2001 From: Addison Hanrattie <40609224+supersimple33@users.noreply.github.com> Date: Wed, 10 Sep 2025 19:39:29 +0000 Subject: [PATCH 2/4] Add swiftdata import --- Sources/TablerSort.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/TablerSort.swift b/Sources/TablerSort.swift index aab3260..6317f09 100644 --- a/Sources/TablerSort.swift +++ b/Sources/TablerSort.swift @@ -17,6 +17,7 @@ // import SwiftUI +import SwiftData public struct TablerSort where Element: Identifiable From 85bfb65a4c69a8f7364bf36b6a00760831502efc Mon Sep 17 00:00:00 2001 From: supersimple33 <40609224+supersimple33@users.noreply.github.com> Date: Wed, 10 Sep 2025 16:46:54 -0400 Subject: [PATCH 3/4] Checking whether swift data is @available --- Sources/TablerSort.swift | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Sources/TablerSort.swift b/Sources/TablerSort.swift index 6317f09..7ad3792 100644 --- a/Sources/TablerSort.swift +++ b/Sources/TablerSort.swift @@ -156,37 +156,69 @@ public extension View { func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } /// Swift-data support + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } + @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } private func xlat(_ direction: TablerSort.Direction) -> SortOrder { From 12a73c09369f0574500d06f7f7501eace321064c Mon Sep 17 00:00:00 2001 From: supersimple33 <40609224+supersimple33@users.noreply.github.com> Date: Wed, 10 Sep 2025 16:50:05 -0400 Subject: [PATCH 4/4] Bad ns object --- Sources/TablerSort.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Sources/TablerSort.swift b/Sources/TablerSort.swift index 7ad3792..8d00e11 100644 --- a/Sources/TablerSort.swift +++ b/Sources/TablerSort.swift @@ -157,10 +157,6 @@ public extension View { /// Swift-data support @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) - func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } - @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) - func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } - @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) } @available(iOS 17.0, macCatalyst 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *) func tablerSort(_ c: Binding>, _ k: KeyPath) -> SortDescriptor { SortDescriptor(k, order: xlat(updateSort(c, k))) }