You think you think that's what you think it is?
- You think your code is OK?
- What do you think you are, Daniel?
- You think that's what you think it is?
- Does your code stand the test? (PS: Does love stand the test?)
iOS debugging a lot of tricks, through debugging we can not only quickly find the location of the bug, more able to optimize the code, so you think it is no longer you think! First, breakpoint normal breakpoint
When the runtime encounters a breakpoint it stops for debugging by the programmer
We clearly see that at this time I is still equal to 0, the function in a named Viewcontroller
There are five optional buttons in the
Cancel the breakpoint button, continue with the step button, step into the button, go out button
Conditional breakpoint
Click the Edit Breakpoint button on the right of the breakpoint
Explain:
Uilbel in the back of condition we can write conditional statements such as i==5, at which point the breakpoint will only take effect when the breakpoint is i==5.
Similarly, we can set the number in the Lgnore, which means ignoring the previous number of executions, in the number + 1 o'clock
will only take effect.
When we want to see which function executes the number of times, you can set the action to log Message, as shown in:
Remember to make sure you put the following check mark on it.
Exception Breakpoint
Note that this breakpoint feeling is the most practical
We often encounter the program debugging process crashes, tens of thousands of lines or even hundreds of thousands of lines of code, crashes will run into the Mian function, it is not clear
Where there is a problem, want to add normal breakpoint debugging do not know where to add, such as:
See this you are not the expression: duang~ general collapse
At this point we need to add to the exception breakpoint, join the method as follows:
So we have a crash ~ ~ ~
dang~ Xcode directly helps us to get into the place where the crash is caused, making it easy to modify
Configure breakpoints: Add functions, class breakpoints according to usability
By configuring breakpoints, we can make a terminal in a class or a method
The practice is to add the corresponding function or class to the Symobol in accordance with the specific requirements
Code run time
After we have completed a project, we have to debug, in order to maximize the software flow, sometimes need to optimize the code, this time we need to find which
The code is time-consuming, figuring out how to optimize the algorithm or opening up multiple threads to ensure a good user experience. The method of measuring time is used.
NSDate *startTime=[NSDate date];for (i=0; i<100000; i++) { NSLog(@"NSLog:%d次",i);}NSLog(@"Time is:%f",-[startTime timeIntervalSinceNow]);
It is recommended that you define a macro variable in the PCH file about the use of the PCH
can refer to my this blog
#define STARTTIME NSDate *startTime=[NSDate date];#define ENDTIME NSLog(@"Time: %f", -[startTime timeIntervalSinceNow]); STARTTIMEfor (i=0; i<100000; i++) { NSLog(@"NSLog:%d次",i);} ENDTIME
还有LLDB、Profile等东西需要细细总结,但因每天晚上要跑步就先到这里啦,明天找时间补充~~~ O(∩_∩)O
iOS Debugging Kit Kat Kinky (i)