The code Snippets Library for Xcode development techniques

Source: Internet
Author: User

http://blog.csdn.net/lin1986lin/article/details/21180007

Directory (?) [-]

    1. Introduction
    2. What is Code Snippets
    3. How to create a new code Snippets
Introduction

In project development, we can often see the following code:

1 @property (nonatomic, copy) NSString *isbatchapprove;2 @property (nonatomic, copy) NSString *currentresult;3 @property ( nonatomic, copy) NSString *strversion;4 @property (nonatomic, copy) NSString *operatetype;

At first glance, no problem, but in the process of doing project development, is actually more troublesome, because the same content as shown below, we need to write many times, virtually to our development increased workload. So is there any way to avoid this repetitive workload? This is the code Snippets Library to be said here.

@property (nonatomic, copy) NSString
What is Code Snippets

In fact, in the process of project development, we have enjoyed the convenience of code Snippets many times, as shown in:

When we enter the SW, it will automatically appear in the back of so much content, click the Enter key, the content is automatically written. This is code Snippets, which is designed to enable programmers to enter frequently used code snippets at the fastest speed and improve programming efficiency. This feature has been introduced from XCODE4, where we can set the display code Snippets as follows:

After setting up the display, we can see Code Snippet, which has a lot of xcode snippets in it, and the switch in the example above is one of them. Double click on a specific code Snippet, you can see the code Snippet details, click the Edit button, you can see more content (new code Snippet when introduced)

How to create a new code Snippets

From the above introduction, for the code snippets benefits, we should be very clear. Once you're clear, you'll have a question: Can you create a new code snippets in Xcode? The answer is yes, below we will introduce the creation of the property in the introduction, step by step the code snippets created process.

The first step: Write code Snippets. Write the following statement where the @property attribute is declared:

@property (nonatomic, copy) nsstring *< #name #>;

Above < #name the effect of #>, can be known in the later use effect.

Step Two: Create a new code Snippets. Select the statement written in the first step, drag the left mouse button to the code Snippets indicated in the area of Xcode, and create a new code Snippets. The effect after the new is as follows: "Property description":
    • Title of the 1.title:code snippets;
    • 2.summary:code snippets's descriptive text;
    • 3.Platform: can use code snippets platform, have Ios/os x/all three options
    • 4.Language: In which languages you can use the Code Snippets
    • 5.Completion Shortcut:code snippets shortcuts, such as the second part of this article to write the switch code snippet to use the SW, here, the property set the shortcut to the PC
    • 6.Completion Scopes: Which files can be used in the current code Snippets, such as all locations, the header file is medium, of course, you can add multiple supported locations.
    • 7. The last large empty area is a preview of the effect of code snippets.
When everything is set up, click the Done button in the lower right corner of the menu and the new job is finished. The use of code Snippets we have two ways to use code Snippets, or the newly defined PC properties code Snippets as an example: in the right place (because the code snippet can be set when defining the use of the platform, the use of language, the use of files and other restrictions),   To enter the PC, you can pop up the following prompt box. Click Enter to appear as follows: Way two: Directly in the Code Snippets section to find the code Snippets we need to use the left mouse button to drag the code Snippets to the appropriate location.

Backup of Code Snippets

The code snippets in Xcode is placed by default in the following directory:
~/library/developer/xcode/userdata/codesnippets   
We can either back up the code snippets in the directory or copy it directly to a different computer, so there is no pressure to collaborate with multiple computers.

Code Snippets commonly used in project development

Here are some of the snippet that I used frequently in my project, for reference only.

1.Notification add: Adds a notification.

2.Notification Remove: Remove notifications.

3.Notification Post: Publish Notifications.

The properties of the 4.Property copy:nsstring type.

5.Property Retain:retain property.

6 .....

The code Snippets Library for Xcode development techniques

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.