preface
Xcode has a code block tool, we only need to enter a prefix or the corresponding prompt to generate code block prompt, such as singleton dispatch_once code block
In Xcode we can also set up our usual Code blocks to improve our development efficiency, called Code Snippets
Set the Code block Code Snippets
First select the code block you wrote, then click on the navigation Editor and select the create Code Snippet at the bottom to go to the Settings page, as shown below
Note: The code block must be selected, otherwise clicking Create Code Snippet will not create a new code block, nor will it create a duplicate code block
A code block is created as shown below, with the title at the top, showing the title on the left, and completion at the top, which is our shortcut character, giving a hint when you type some or all of the shortcut characters
For example, we set the assign property attribute, and the shortcut string is lsassign
For example, if you set a singleton like the property property above, you need to control the type and name of the code block. The code block needs to be defined as follows
@property (nonatomic, assign) <#type#> *<#name#>;
Copy the code
Then it’s safe to use
The following is a block of code for the singleton. The Settings are more fixed, and it can be called by printing the sharedInstance part