IOS debugging-breakpoint debugging and Dynamic Output

Source: Internet
Author: User

IOS debugging-breakpoint debugging and Dynamic Output

During App development, we need to modify and optimize our code repeatedly. In particular, when a program encounters a bug, We need to quickly find out the cause of the error and modify it, to ensure the proper execution of the program.

Breakpoint debugging is the most common and simple debugging method. You can track the program execution process step by step, get the variable value, and quickly find the cause of the error.

1. Basic breakpoint operations

Breakpoint operations are very simple. The following figure shows how to add, delete, edit, and use breakpoints.

2. Global breakpoint

Set a Global breakpoint (exception breakpoint). When an error occurs, the Debug program automatically locates the stack bottom information, that is, it jumps to the row where the error code is located.

3. Conditional breakpoint

When a condition breakpoint is set, the breakpoint is triggered only when the condition is met. It is suitable for loop structure and can be accurately located in a loop.

4. symbol breakpoint

A symbolic breakpoint can interrupt a specified function call, locate an exception code, and print the exception information.

5. NSLog output

During debugging, NSLog is often used to output the required information on the console. NSLog output consumes system resources, and the output data may expose the confidential information in the App. All NSLog output must be blocked before the official version is released.

In addition to the basic output information, NSLog can also output struct data at one time.

6. Dynamic Output

In the debugging process of a program, you can view the variable value under Xcode through breakpoint debugging, or use NSLog to output the desired information on the console. To use NSLog output, you need to write the information you want to output before running. If there is any change, you need to re-compile and run it, which is very inefficient.

The following describes a very simple and practical method. When the program is running, you can quickly print the required information by entering corresponding commands on the console.

There are two commands for dynamic output: p and po. Similar to NSLog usage, p is used to print output common information, and po is used to print output object information. Dynamic commands must be used with breakpoints to dynamically print the information when the output program runs to a breakpoint.

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.