iOS Debugging Fundamentals

Apr 27 2021 · Swift 5, iOS 14, Xcode 12

Part 1: iOS Debugging Fundamentals

05. Challenge: Breakpoints

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 04. Inspecting Variables Next episode: 06. Control Flow

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Transcript: 05. Challenge: Breakpoints

Welcome back! I now have all the tools I need to begin get rid of the bugs in at least one room in my house. And you, on the other hand, have all the tools you need to fix the next bug; and that’s finding out what’s wrong with the missing tasks.

In this challenge, you’ll use all that you’ve learned so far in order to find out why, when you run your project, your list is missing tasks for the low, medium, and high priorities, which are also not showing up in your list.

If you get stuck, set some breakpoints in TaskStore.swift and look at the prioritizedTasks array in more detail.Pause the video and come back when you’ve found the problem. I’ll be here taking care of my bugs too!

As is usually the case when debugging, there are multiple ways you could narrow down where this bug is. Since the TaskStore is responsible for creating the initial array of prioritizedTasks, it makes sense to start by setting a breakpoint there.

You can use the Variables View and the Console to see what’s going on. Make sure TaskStore.swift is open and set a breakpoint on line 67. This is the last line for your prioritizedTasks property.

Run your app and, when the breakpoint hits, expand the $0 variable, and then expand the tasks. Ok, just as expected, and as can be seen a few lines lines above, we have four tasks under the high priority. Click Continue a few times, each time noticing how the priority and tasks change.

So what is the issue? Well, take a look at the line of code where you set the breakpoint. I must have left some test or old code in here that filters all of our prioritized tasks in order to just return those with a priority of none.

Go ahead and remove the filter code, and run you app again. Yay! You can now see many more tasks showing up under all four priorities.

There are still bugs, like seeing a triangle instead of a checkmark for any tasks that are completed, as well as no text for each task.

But you’ve gotten rid of one more bug in your app, and I managed to clean out and remove the bugs in one room in my house. Great work once again, fellow Detective Pikachu!

In the next episode, you’ll learn more about controlling the flow of execution and how that can help you when debugging your code. See ya then! :)