iOS Debugging-breakpoint debugging and dynamic output

Source: Internet
Author: User

In the process of developing the app, we need to revise and optimize our code repeatedly, especially when the program bug, need to quickly find out the cause of the error, make changes to ensure the correct execution of the program.

Breakpoint debugging, is the most commonly used the simplest kind of debugging, can step by step tracking program execution process, get the value of the variable, quickly find the cause of the error.

1, the basic operation of the breakpoint

The operation of the breakpoint is very simple, with a few diagrams below to explain how to add, delete, edit, and use breakpoints.

2. Global Breakpoint

Sets a global breakpoint (an exception breakpoint), and when an error is encountered, the debug program automatically navigates to the bottom of the stack, jumping to the line where the error code is located.

3. Conditional breakpoint

Set a conditional breakpoint, when the condition is met, the breakpoint is triggered, suitable for use in the loop structure, can be accurately positioned to a loop.

4. Symbol Breakpoint

A symbolic breakpoint can break a call to a specified function, or you can navigate to the code where the exception occurred and print the exception information.

5, NSLog output

During debugging, it is often necessary to output the required information through the NSLog on the console. The NSLog output consumes system resources, and the output data may reveal confidential information in the app, where all nslog output must be masked before the release of the official version.

NSLog In addition to the output of basic information, for the structure can also be output once.

6. Dynamic output

In the course of debugging the program, you can also output the desired information from the console by NSLog, in addition to viewing the values of the variables under Xcode by debugging breakpoints. Using the NSLog output requires that you write the information you want to output before you run it, and that if there is a change, it needs to be recompiled to run, very inefficient.

The following is a very simple and practical way, in the process of running the program, by inputting the corresponding instructions in the console, you can quickly print out the required information, very convenient.

The dynamic output instructions are two, p and Po, similar to NSLog usage, p is used to print out general information, and PO is used to print out object information. The use of dynamic directives is used in conjunction with breakpoints, which enables the dynamic printing of information when the output program executes 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.