Leave a rating/review
Welcome back. I have now gotten rid of all of the bugs in my house and learned a lot about debugging in the process. The Task List application, however, has one last bug that you’re going to help fix in this challenge.
You may remember from episode 2 that when the plus button is tapped, nothing happens, which means there is no way create a new task right now. That’s precisely what you’re going to fix!
If you get stuck, set check out ContentView.swift, and focus on the sheet modifier along with its isPresented binding. Pause the video and come back when you’ve found the problem.
How did it go? This one was certainly a tricky one. The sheet modifier presents the NewTaskView when its isPresented parameter is set to true. In your application, that’s controlled by the modalIsPresented property.
In line 37 you can see that this property defaults to false. Tapping the plus button should set it to true within the button’s action.
Ahh, but it’s just setting it to false, which will never trigger the sheet presentation.
With the help of breakpoints, the variables view, and the console, hopefully you were able to get to this point. If not, don’t worry. Debugging is hard and some bugs can be quite difficult and time-consuming to fix.
To fix this final bug, change line 51 to read as follows:
self.isModalPresented = true
Run your app, click the plus button, and add some details for your task.