I can’t understand why app doesn’t have this in its docs but I am letting the user select a month and show in a list only the records that are from the month the user selected;
@State private var selectedDate: Date = Date.now
Button {
selectedDate = Calendar.current.date(byAdding: .month, value: -1, to: selectedDate) ?? selectedDate
} label: {
Image(systemName: "chevron.left")
}
And then I try to use it in a predicate:
static var fetchDescriptor: FetchDescriptor<Workout> {
let date = Date.now
let descriptor = FetchDescriptor<Workout>(
// predicate: #Predicate { $0.endTime == selectedDate },
sortBy: [
.init(.endTime, order: .reverse)
]
)
//descriptor.fetchLimit = 6
return descriptor
}
@Query(fetchDescriptor) private var workouts: [Workout]
but it throws the error Key path cannot refer to static member now. How do you let a user filter their data by data in SWiftUI?