XCode debuggingTip settingsGlobalThe line where the breakpoint is located and the problem code is located is described in this article.DebuggingWhen the program is running, we would like to immediately know which line of the error code is. Instead of setting a breakpointDebuggingFind the line of code that eventually caused the program to crash. You can use the following method to quickly locate the problem code.
Method 1:
Select Run> Show> Breakpoints to go To the breakpoint window.
Xcode breakpoint window
First, you must create a breakpoint for-[NSException raise. Select Global Breakpoints, Double-click for Symbol, enter-[NSException raise], and press return.
After the breakpoint-NSException raise is added
Next, add another Global breakpoint objc_exception_throw according to the preceding steps.
When an exception occurs in a running program, the debugger stops running the program and points to the problematic code line.
Method 2:
There are many exceptions, and the program will exit directly if the breakpoint cannot be normally accessed, for example:
At this time, we do not even know where this error occurs. OK, Open Run> Debugger to find the exit position of the program:
Then Add a soft breakpoint Run-> Manage Breakpoints-> Add symbolic breakpoint and enter objc_exception_throw
Run againDebugging:
Is it easy to find the error :)
The first method is available, and the second method can also be used...
Summary:XCode debuggingSetGlobalThe contents of the line where the breakpoint is located and the problem code is located are described. I hope this article will help you!