Now look at the Variables tab: the decoder variable has appeared and you can see all the properties of the newly created JSONDecoder object when expanding this variable. The error that we’ve got ( Expected to decode Double but found a string/data instead) most likely relates to the JSONDecoder object which hasn’t been created yet.Ĭlick or press F8 to execute the next code line - let decoder = JSONDecoder(). At this point, we see that the conference data (the conferenceData variable) is successfully loaded from the local JSON file. The Frames tab displays a stack of method/function calls, and the Variables tab - a list of variables available in the current context. The program execution stops at the line where the breakpoint is set, and now we can examine the current program state in the Debug tool window that opens: Start the debugging session by pressing ⇧ F9.
Set a line breakpoint at line 24: click the gutter area left to the code line or press ⌃ F8. Thanks to the do.catch block used in this code fragment, we can see that the error occurred on decoding the JSON file. To do this, you can press ⌃ ⇧ N and in the dialog that opens type :27. Open the file specified in the error message and go to line 27. Let's set a line breakpoint, step through the suspended program to examine its state, and inject the code that will fix the bug at runtime. Expected to decode Double but found a string/data instead.