Xcode the use of custom code block in Xcode custom code block

Source: Internet
Author: User

In the lower-right corner of the Xcode, there is an icon with two curly braces, which is the custom code block.

For example, the following figure is a for-loop system custom code block, drag it into the code area, it can be used directly, very convenient.



The following is the appearance of dragging a code block into the code area, and the same hint as writing a for loop directly.


Of course, in addition to using compiler-defined blocks of code, we can also make custom blocks of code:

First, select a statement that we want to set as a block of code, and then press the left mouse button to drag the statement directly to the lower right to display the area of the code block.



Click to find this look like this:




Then we go to edit (edit) for specific settings:


The title of the 1.title:code snippets;

2.summary:code snippets Description of the text;

3.Platform: can use the Code snippets platform, there are Ios/os x/all three options

4.Language: Which languages can you use this code Snippets

5.Completion Shortcut:code snippets shortcuts, such as the second part of this article to write the switch code snippet used in the SW, where the property set shortcut to the PC

6.Completion scopes: You can use the current code Snippets in which files, such as all locations, the header file is medium, and of course you can add multiple supported locations.

7. The final large blank area is a preview of the effect on the code snippets.




We need to change the main place is Title, completion shortcut (shortcut) and set replaceable characters replace Appview with < #view #> placeholder, replace Bluecolor with < #color #> placeholder

Note that there are two of them here, the last one to be written, or the placeholder will be generated immediately.

Also note that add a little completion scopes to set to all.

So, after we click the Done button, we can use this block of code.


The red section is a custom block of code that we drag into the code area, just to change the placeholder area before and after.

Can also be written by shortcut, there will be a hint.



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.