Code block in Xode), xode code

Source: Internet
Author: User

Use the code block (conversion) and Xode code in xode

During our coding process, we will always find some repetitive coding work, and you may not bother copying and paste, but have you considered how to solve this problem? In fact, many programming ides can help us reduce some coding tasks and improve coding efficiency. Today, let's learn how to define some common code snippets in Xcode.

In fact, in the process of programming, I believe many friends will use it, such:

<Ignore_js_op>



Here, we can directly select and drag to our code editing area to quickly generate the code Block we need. For example, we select C ++ Try/Catch Block, drag the code into our editing area and the code is automatically displayed in front of us, for example:

<Ignore_js_op>



It seems that it will save a lot of time and effort. During our coding process, a lot of code will be written repeatedly. For these regular needs, the code is extremely cumbersome, there are obvious commonalities (or fixed ones), so we can consider why we can't define them as code blocks. Let's take a look at how to do it.

1. Write your code in the code editing area (for example, define an attribute here ):

[Objective-C] view duplicate code in plain text
@property (nonatomic , strong) <#type#> <#name#>



You enter <# type #> In Your Xcode to display the following results (you can give it a try ):

<Ignore_js_op>



2. After the input is complete, select the code you just entered and click the left mouse button. Do not open it. Drag it to the code snippets panel on the right (for example ):

<Ignore_js_op>



3. Select the code block you just dragged in, and click the left mouse button to bring up a panel on the left, for example:

<Ignore_js_op>



4. Click the-Edit-button. The Edit panel is displayed as follows:

<Ignore_js_op>



5. Edit the settings below. The first is the Title, which is the Title (name) displayed in the Code snippets panel on the right; the second is the Summary, which should be understandable, write down the overview you need to express. For the third platform, you can select All/IOS/OS X from the root drop-down list. For the fourth platform, you can use Langauge, you can choose it by yourself. The fifth one may interest you, that is, setting the shortcut key. For example, if you enter @ ps and save it, you can enter the shortcut key for encoding, it is very convenient; The sixth is the effective region of the Snippets, you can also choose.


6. OK. Click-Done-to save the settings. After saving the settings, enter the shortcut key:


<Ignore_js_op>



In this way, you only need to enter the shortcut key you set for the input, you can quickly generate the code you need, this is not a small help for some code that needs to be repeatedly entered, for example, you often need to create entity class definitions.

At the end of the article, I would like to recommend some useful things: VVDocument-Xcode standard comment generator, CodePilot-all-around search tools, ColorSense-Xcode color recognition and preview plug-ins (often gray ), KSImageNamed-Automatic completion of image file names and display of a thumbnail of the image (gray stick), XAlign-regular code alignment plug-in that can customize alignment mode, cocoapods-third-party class library management tools and project dependency management artifacts (the most recommendable 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.