introduction
In project development, we can often see the code as shown below:
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 look, no problem, but in doing project development, in fact, is more trouble, 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 such repetition of work it? This is the point here Code Snippets Library.
@property (nonatomic, copy) NSString
What is the Code Snippets
In fact, in the course of project development, we have many times to enjoy the convenience brought us the Code Snippets, such as shown in the following figure:
When we entered the sw, so much behind the content will automatically appear, press the Enter key, the content will automatically write better. This is the Code Snippets , object is to enable programmers to enter the fastest commonly used code fragments, to improve programming efficiency. This feature from start to introduce Xcode4, we can set the display Code Snippets in the following places:
After setting the display, where we can see in the following Code Snippet, there are many Xcode own code fragment, is the embodiment in which a switch. Double-click on a specific Code Snippet, you can see the details of the Code Snippet, click the Edit button, you can see more content (the new Code Snippet when re-introduced )
How to Create Code Snippets
Through the above description, for the benefits of Code Snippets, it should be very clear. After clearly useful, we have a problem: XCode can create your own Code Snippets do? The answer is yes, let's create a property through the introduction of a step by step introduction to Code Snippets process created.
The first step: Writing Code Snippets . Wrote the following statement in place declared @property properties:
@property (nonatomic, copy) NSString *<#name#>;
The above <# name #> role in the use of the latter effect may be known.
- 1.Title:Code Snippets的标题;
- 2.Summary:Code Snippets的描述文字;
- 3.Platform:可以使用Code Snippets的平台,有IOS/OS X/All三个选项
- 4.Language:可以在哪些语言中使用该Code Snippets
- 5.Completion Shortcut:Code Snippets的快捷方式,比如本文第二部分编写switch代码段用到的sw,在这里,把属性设置的快捷方式设为pc
- 6.Completion Scopes:可以在哪些文件中使用当前Code Snippets,比如全部位置,头文件中等,当然可以添加多个支持的位置。
- 7.最后的一个大得空白区域是对Code Snippets的效果预览。
Code Snippets的备份
~/Library/Developer/Xcode/UserData/CodeSnippets
项目开发中常用的Code Snippets
下面是我在项目中经常使用到的一些snippet,仅供参考。
1.Notification Add:添加通知。
2.Notification Remove:移除通知。
3.Notification Post:发布通知。
4.Property Copy:NSString类型的属性。
5.Property Retain:retain属性。
6........
转载于:https://www.cnblogs.com/eagle927183/p/3594292.html