iOS Debugging-breakpoint debugging and dynamic output

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.