I've just begun running into this error and I've seen that a few others have had this problem as well but there never seems to be a general solution.
Full error: The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
I know my code isn't necessarily optimized per se but I don't think this should be happening
var body: some View {
return NavigationView {
List {
ForEach(tasks, id: \.dueDate) {
TaskRow(task: $0)
}.onDelete(perform: deleteTask)
Section(header: Text("Projects")
.font(.title2)
.fontWeight(.bold)
.foregroundColor(Color.pink)) {
ForEach(projects, id: \.projectTitle) {
ProjectRow(project: $0)
}.onDelete(perform: deleteProject)
}
}.toolbar {
ToolbarItem (placement: .primaryAction) {
#if os(iOS)
EditButton()
.padding(10)
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
#endif
}
ToolbarItem (placement: .bottomBar) {
Button(action:
self.isAddingTask = true
self.isAddingProject = false
self.isPresenting = true
}) {
Text("Add Task")
.fontWeight(.semibold)
}.padding(10)
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
}
ToolbarItem (placement: .bottomBar) {
Button(action: {
self.isAddingTask = false
self.isAddingProject = true
self.isPresenting = true
}) {
Text("Add Project")
.fontWeight(.semibold)
}.padding(10)
.background(Color.pink)
.foregroundColor(.white)
.cornerRadius(10)
}
}
.sheet(isPresented: $isPresenting) {
if isAddingProject {
AddProject() { projectTitle in
self.addProject(projectTitle: projectTitle)
resetModal()
}
} else if isAddingTask {
AddTask() { taskDescription, dueDate in
self.addTask(taskDescription: taskDescription, dueDate: dueDate)
resetModal()
}
}
}
.navigationBarTitle(Text("Tasky"))
}
The error says it's happening at the Navigation View but I have a sneaking suspicion Xcode doesn't actually know.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I've been playing around with EventKit with SwiftUI trying to make my own version of a Reminders client, however, most of the tutorials or articles I've found really only explain it from a UIKit perspective and I'm not exactly sure how to make that applicable to SwiftUI, the documentation for EventKit is also of little to no help.
Is there an article or example somewhere that shows how to do this?