9 super-useful tips for IOS development

Source: Internet
Author: User
Tags stack trace

1. How to quickly see the execution time of a piece of code.

12 #define TICK   NSDate *startTime = [NSDate date]#define TOCK   NSLog(@"Time: %f", -[startTime timeIntervalSinceNow])

Do this where you want to see the code for the execution time

123 TICK//do your work hereTOCK

2. How to quickly see the number of calls to a function without adding a single line of code. Such as

This method is suitable for an if method, a for loop, and does not interrupt the program, and does not need to add a line of code. But be sure to check the following automatically continue after evaluting actions;

3. When using the zoom of the view, layer.border.width with the view magnification, there will be a jagged problem, to solve this problem need to set this property.

1 self.layer.allowsEdgeAntialiasing = YES;

Self in Time profile in 4.instrument, #self, what does%self represent?

The following is a reference to the specific content on the Internet

"Self was" the number of times the symbol calls itself. "According to the Apple Docs on the time Profiler.

From the the-the-numbers look though, it seems-the summed duration of samples that had the "this symbol" at the bottom O f its stack trace. That's would make:

Self:the number of samples where this symbol is at the bottom of the stack trace

% self:the percent of self samples relative to total samples of currently displayed call Tree

(eg-#self/total samples).

So the wouldn ' t tell you how many times a method is called. But it would give what much time is spent in a method or lower in the call tree.

5. How to quickly add a global exception breakpoint (one step to the top three steps). and add a Symbloic breakpoint, (step or top three) add a breakpoint without using a mouse

See the picture, add these breakpoints completely do not need to move the mouse (with my boast B), add a separate breakpoint when the mouse moved, but that is I deliberately let you see I have a mouse.

    • First of all exception breakpoints are very common, this I use a shortcut key to do! By changing the key command +p to add an abnormal breakpoint, to say how to change, turn my previous blog to go!

    • Then add Symbloic shortcut keys for commnamd + OPTION + \

    • The shortcut key for adding a single line breakpoint is COMMAND + \

6. In the development of iOS, we often need to intercept the screen of the mobile phone or the screens on the simulator when we communicate with the product and design, and we may use the Home button + power on the phone, and then pass it through IPhoto or QQ on the phone. But I teach you a way to use shortcut keys to intercept the pictures on your phone directly onto your computer desktop.

See below for specific methods:

Find Viewdebugging in the Debug menu of Xcode, even if the current program is not running, you can directly intercept the picture on the phone directly to the desktop. (Hahaha does not need the TM's phone button on the TM to be copied to the desktop by iphoto). Young man, do you think it's over? You are still too young Ah, who TM want to find this debug menu to find the following a bunch of things, of course, to change to shortcut keys, how to do look.

See this red arrow of blood dripping, you first find the Debug shortcut menu item, in the change it to? +? This, when there is a conflict? You don't know if there is any effect on other shortcut keys what to do, little fool, change Bai! Remove the previous function? +? (PS: The previous is show complete list like click one?), why do you want it to do?), why change to this part listen to brother, you change into this cliff will be used particularly cool. (OK later to give the product or design hair map minutes of things ~ ~)

7.iOS Debugging techniques Show only the alignment dimensions and frame of the picture.

I remember the previous one that said the alignment size, he did this:

"Setting a startup parameter Uiviewshowalignmentrects in the edit scheme of the project and setting the parameter value to Yes allows the program to display the view's alignment matrix (alignment rectangle) at run time. ”

I did not read it at that time, so complicated who use AH. You really think I'm going to be a b again, okay, you guessed it, I'm actually faking B, and you can see what I'm doing with B.

Maybe I switch the picture faster, the effect you did not see the obvious. You can try it on your own, this can be toggled at any time to show showalignmentrect, or the size of each control including the system's control (such as the system's UIButton it will show the internal ImageView size and label size and then different color differences, Xcode color distinction is still quite beautiful)

This Nima is a big kill device, with this your control of the size of the display is not the same as I said before the lldb, and convenient, you ask me how to do, I do not configure spicy many of a pair of parameters, I also do not bother to remember, of course, I am using shortcut keys! Careful classmate may notice in front of viewdebuging in have Showviewframe and showalignmentrects, of course click these menu will appear I these effect, I of course again change shortcut key, my time is very precious.

8. We often use git in our development, and then we modify this file do not know where to change the wrong, we often need to recover this file, so we may be cut to the terminal, may also directly use Xcode to discard the file modification, fortunately Xcode on the source Control support is good, so we can modify these methods of shortcut keys to quickly recover files, here are some of my settings, with a good cliff to improve your efficiency.

For me it is often used to give up the changes of the current file and discard all the changes, and look at Git history if the current file changes when it is not back to the correct, these things can play a big role!

9. In IOS we often encounter some imagview of the Uicontentmode display way, initially I do not know how to remember, and then I saw this picture, I found that I met the Beacon, a diagram of the confusion, here to share to everyone. (PS: People don't say I'm a vegetable.)

9 super-useful tips for IOS development

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.