"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.
- #pragma mark-uiviewcontroller Overrides
By pragma mark, you can make your code look neat and organized. While this is important, it brings additional input operations and time. At this point, we can use code snippets. With code snippets, we can create reusable blocks of code that can be easily used wherever needed. This saves you the input needed for the operation and time. And once you learn to use code snippets, you'll find that you can create and expand your own code snippet library. Creating a code snippet is very simple. First, open Xcode and select the code snippet library in the utilities panel. , you can see that there is already some data in the code Snippet library. Then, enter the code snippet you want to create. Here, I create a code snippet for pragma mark. Enter "#pragma mark–uiviewcontroller overrides" in the code editor, as shown in. Select the code block as shown in: Then click and hold the code block to know that the text cursor changes to an arrow cursor. Then drag and drop the block into the code snippet library and release the mouse. As shown here, a popover pops up and the new code snippet can be edited as shown in the PopOver. First, it is the name of the snippet. Here I specify "Pragma Mark" and then specify the completion shortcut (optional) for the snippet. Here I am designated as "PM". Once this is set up, you can simply add this snippet to your code by just entering the shortcut (PM) in the Xcode code Editor. Very useful! Then, as you can see in the example above, the title of pragma mark is "Uiviewcontroller overrides", but we want to modify it to make it easy to enter any title. We can simply modify the text content contained in code snippet to "#pragma mark–". However, there is a better way to encapsulate text blocks in the middle of "<#" and "#>", so that code snippet will indicate that we can insert the full range of custom text. Replace "Uiviewcontroller overrides" with "< #Title #>" below。 Note that the completion scopes field is not modified here, and this field allows you to specify a valid range of completion shortcut. Finally, click the Edit button to finish editing the snippet. You can then see a preview of the final result in this popover screen. Then click the Done button in PopOver. Below, you can delete the lines of text that we wrote in the Code editor for creating snippet. Now try out the snippet! you just created There are two ways. The first is to find snippet in the Code snippet Library and then drag it to the editor with your mouse ... Then release the mouse. Once snippet is dragged and dropped into the Code editor, you can move the focus between different completion fields by tapping the TAB key on the keyboard. The second method is to simply enter the contents of the completion shortcut in the Code Editor. We are here "PM". You can then insert the snippet into the code Editor by tapping the return key in the keyboard. It's simple! Now that you know how to create your own snippet, you will find it very useful. Any time you encounter the same block of code that you have repeatedly entered, you can consider adding it to your Code snippets library. Here are some of the snippet: that I used a lot
- Title:animation Block
- Completion Shortcut:ab
- Completion scopes:function or Method
- void (^< #Title #>) (void) = ^{};
- Title:animation Completion Block
- Completion SHORTCUT:ACB
- Completion scopes:function or Method
- void (^< #Title #>) (bool) = ^ (bool finished) {};
- Title:notification ADD
- Completion Shortcut:na
- Completion scopes:function or Method
- [[Nsnotificationcenter Defaultcenter] addobserver:< #Observer #> selector:< #Selector #> name:< #Name # > object:< #Object #>];
- Title:notification Remove
- Completion SHORTCUT:NR
- Completion scopes:function or Method
- [[Nsnotificationcenter Defaultcenter] removeobserver:< #Observer #> name:< #Name #> object:< #Object # >];
- Title:nslog
- Completion Shortcut:log
- Completion scopes:function or Method
- NSLog (@"< #Log #>");
- Title:private Interface
- Completion SHORTCUT:PI
- Completion scopes:top Level
- @Interface < #Title #> ()
- @end
- Title:property Assign
- Completion SHORTCUT:PA
- Completion Scopes:all
- @property (Assign, nonatomic)
- Title:property Strong
- Completion Shortcut:ps
- Completion Scopes:all
- @property (Strong, Nonatomic)
- Title:property Unsafe unretained
- Completion SHORTCUT:PU
- Completion Scopes:all
- @property (unsafe_unretained, nonatomic)
Xcode Development Tips--code Snippets