IOS debugging (1)

Source: Internet
Author: User

IOS debugging (1)

What do you think is what you think?

Do you think your code is very OK? What do you think you are? What do you think is what you think? Can your code stand the test? (PS: Can you stand the test?) There are many iOS debugging skills. Through debugging, we can not only quickly find the Bug, but also optimize the Code, so that you don't think it is what you think! I. breakpoint normal breakpoint

When a breakpoint occurs during running, it is stopped for programmers to debug. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4NCjxwPjxpbWcgYWx0PQ = "here write picture description" src = "http://www.bkjia.com/uploads/allimg/160326/04153330Y-2.png" title = "\"/>

We can clearly see that at this time, I is still equal to 0. This function is in a ViewController

There are five optional buttons

They are the cancel breakpoint button, continue to execute one step button, step into button, and step out button.

Conditional breakpoint


Right-click the Breakpoint and choose Edit Breakpoint.

Explanations:

In the UILbel following Condition, we can write Condition statements such as I = 5. At this time, the breakpoint takes effect only when I = 5.

Similarly, you can set a number in lgnore to ignore the number of previous executions.

.

If you want to see how many times the function has been executed, you can set it to Log Message in Action, as shown in:

Remember to mark the following check mark.

Exception breakpoint

Note that this breakpoint is the most practical

We often encounter crashes during program debugging, tens of thousands or even hundreds of thousands of lines of code. After the crash, we will run into the Mian function. It is not clear at all.

If you want to add a normal breakpoint for debugging, you do not know where to add it, as shown in the following figure:

See if you have such an expression: duang ~ General crash

In this case, we need to add the exception breakpoint as follows:


In this case, we encountered a crash ~~~

Dang ~ XCode directly helps us to enter the location that caused Crash for modification.

Configure breakpoints: Add functions and class breakpoints Based on usability

By configuring breakpoints, we can be precise to a class or method for terminals.

The specific method is to add the corresponding function or class in Symobol according to the specific requirements.

Code running time

After we complete a project, we can debug it. In order to maximize the smoothness of the software, we sometimes need to optimize the code. What do we need to find at this time?
Code is time-consuming. You can optimize algorithms or create multiple threads to ensure a good user experience. In this case, the test time is used.

NSDate * startTime = [NSDate date]; for (I = 0; I <100000; I ++) {NSLog (@ "NSLog: % d Times", I );} NSLog (@ "Time is: % f",-[startTime timeIntervalSinceNow]);

We recommend that you define a macro variable in the pch file.

# Define STARTTIME NSDate * startTime = [NSDate date]; # define ENDTIME NSLog (@ "Time: % f",-[startTime timeIntervalSinceNow]); STARTTIMEfor (I = 0; I <100000; I ++) {NSLog (@ "NSLog: % d Times", I);} ENDTIME
There are also LLDB, Profile and other things that need to be summarized in detail, but because we need to run every night, we will first come here, and tomorrow we will find time to add ~~~ O (partition _ partition) O

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.