In the process of developing the app. Need to re-modify and optimize our code, especially when the program has a bug, you need to find the cause of the error at high speed, to make changes to ensure the correct operation of the program.
Breakpoint debugging, is most often used the simplest kind of debugging method, can step by step tracking program running process, get the value of the variable, high-speed to find the cause of the error.
1, the basic operation of the breakpoint
The operation of the breakpoint is easy, following a few pictures to introduce how to add, delete, edit and use breakpoints.
2. Global Breakpoint
Sets a global breakpoint (an exception breakpoint). When an error is encountered, the debug program proactively navigates to the bottom of the stack, jumping to the line where the error code is located.
3. Conditional breakpoint
Sets a conditional breakpoint. When the condition is met, the breakpoint is triggered, which is suitable for the loop structure and can be accurately positioned to a cycle.
4. Symbol Breakpoint
A symbolic breakpoint can break a call to a specified function. You can also navigate to the code where the exception occurred. and print exception information.
5, NSLog output
In the process of debugging. The required information is often output through the NSLog on the console.
NSLog output is more expensive than system resources. The output data may also expose confidential information in the app, where all nslog output must be masked before the official version is released.
NSLog In addition to the output of basic information, for the structure can also be output once.
6. Dynamic output
During the debugging process of the program. In addition to using breakpoint debugging to view the values of variables under Xcode, you can also output the desired information in the console via NSLog. Using the NSLog output requires that you write the information you want to output before executing it, assuming that there is a change and that it needs to be compiled again. Efficiency is low.
Here's an easy and useful way to do this. In the process of program execution, by inputting the corresponding instruction in the console, it is convenient to print out the required information at high speed.
The dynamic output instruction has two, p and Po, similar to the NSLog usage method. P is used to print out general information. The PO is used to print out object information.
Use dynamic directives to use with breakpoints. This is the information that the dynamic print output program runs to a breakpoint.
iOS Debugging-breakpoint debugging and dynamic output