First, the function is introduced from the XCODE4. The location in Xcode is as follows:
For example, the right system defines the right code block, including some declarations and implementations of @interface and @implementation that we use very often.
Ii. Customizing the Code block steps we commonly use
The definition of @property attribute is a common feature in Cocoa program development, as an example of how to customize code snippets.
1. Write Code Snippets
Write the following statement where the @property attribute is declared:
@property (nonatomic, assign) int A;
2. Create a new code snippet
1) Click Code Snippet Library
2) Select User Custom
3) The following blank interface appears
4) Select the code you just edited, drag it to the space above, and the following editing window appears
The meanings from top to bottom in the figure are:
①title
The title of the Code fragment
②summary
Description text for code Snippets
③platform
A platform that can use code snippets with Ios/os x/all three options
④language
Which languages can I use the code snippet in
⑤completion Shortcut
A shortcut to the code snippet, which I set to assign
⑥completion Scopes
Which files can be used in the current code snippet, such as all locations, the header file is medium, of course, you can add multiple supported locations.
The last large empty area is a preview of the effect on the snippet.
Such as:
When everything is set up, click the Done button in the lower right corner of the menu and the new job is finished.
5) Verify the effect: I enter assign in the code, click the Enter key, the code is filled with the following
Third, the backup of the code fragment
The code snippet in Xcode is placed by default in the following directory:
~/library/developer/xcode/userdata/codesnippets
We can back up the code snippets in the catalog, or we can copy them out and put them on different computers.
Xcode Custom code block