Skip to content

Instantly share code, notes, and snippets.

@colinfwren
Created November 19, 2023 21:21
Show Gist options
  • Save colinfwren/83307e89a055fbf99de905278ad77aee to your computer and use it in GitHub Desktop.
Save colinfwren/83307e89a055fbf99de905278ad77aee to your computer and use it in GitHub Desktop.
Date Test Approach 1 fetchMonthData
func fetchMonthData() {
do {
let descriptor = FetchDescriptor<ApproachModel>(predicate: #Predicate { todo in
((todo.startDate >= startDate && todo.startDate <= endDate) || (todo.endDate >= startDate && todo.endDate <= endDate)) && todo.shownInWeek == true
}, sortBy: [SortDescriptor(\.endDate)])
todos = try modelContext.fetch(descriptor)
} catch {
print("Failed to fetch month data")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment