iOS Development-tools: Skillfully use Xcode code blocks to improve coding efficiency-code snippets

Source: Internet
Author: User

Original from: http://www.sufeinet.com/thread-8732-1-1.html

In our coding process, we will find that there are some repetitive coding work, you may be tired of going to copy and paste, but you have to consider how to solve such problems. In fact, many programming Ides can help us to reduce the number of coding tasks and improve coding efficiency. Today we will learn how to define some common code snippets in Xcode.

In fact, in the process of programming, I believe that many small partners will be used, the following figure:



Here, we can directly select and drag to our code editing area, we can quickly generate the code blocks we need, such as we choose C + + Try/catch block, and dragged into our editing area, the code will automatically appear in front of us, the following figure:



This looks like, is not to save time and effort a lot of it. In the process of coding, there are a lot of code that will be written repeatedly, for these recurring needs to be written and feel very cumbersome code, and there is a clear commonality (or is fixed), so we can consider, why not define them as a block of code, in fact, it is possible, Let's see how to do it.

1, first write your code in the code editing area (such as I here to define a property as an example):

[Objective-c] Plain text view copy code

@property (Nonatomic, Strong) < #type #> < #name #>


You enter < #type in your Xcode #> actually shows the effect as follows (you try to know):



2, input complete, first select the code you just entered, and then click the left mouse button, do not let go, drag to the Right Code snippets Panel (as shown below):



3, select the code you just dragged into the block, and then just click the left mouse button, on the left will pop a panel, the following figure:



4, click the-edit-button, will appear Edit panel, as follows:



5, the following can be edited. The first is title, which is displayed on the right side of the Code snippets Panel in the title (name); The second is summary, which you should be able to understand, write down the outline of what you need to express; the third platform, the root can be Drop-down selection (All/ios/os X) Fourth is the language (langauge), haha, a lot of, you choose it; the fifth one may be more interested in, that is, set shortcut keys, such as: You enter @ps, save can be directly entered through the shortcut key to encode, very convenient; The sixth is the effective area of the snippets, You can also make a choice.


6, OK, click on the-done-button to save it, after the save, try the shortcut key to enter it:




In this way, you just need to enter your set of shortcuts to enter it, you can quickly generate the code you need, this is for some recurring need to enter the code is not small, such as often need to create some definitions of entity classes and so on.

At the end of the article, we recommend some more useful things: Vvdocument-xcode specification annotation generator, Codepilot-universal search Tool, Colorsense-xcode color recognition and preview plug-ins (often good), ksimagenamed- The picture file name is automatically fully complement and can display a thumbnail of the picture (Ash stick), xalign-You can customize the alignment pattern of the regular code alignment plug-ins, Cocoapods-third-party class Library management tools and project dependency management artifacts (most recommended artifacts). As an iOS developer, you need to know this.

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.