filmov
tv
How to Create Code Snippets in Xcode 11 (Step by Step Example)
Показать описание
Here's exactly how to create a code snippet in Xcode 11.
Check us out at our website for more content like this:
Text Version:
Hi and welcome back, today I'm going to be showing you how to create a code snippet
in Xcode 11.
As you can see I have a function here called showAlertController, I want to put this into a code snippet so I can use it easily in future projects.
I'm going to do that by highlighting all of the code that I want included in the snippet, then right clicking, and selecting "Create Code Snippet."
This should pop up a menu.
It's going to need a title, which will be the name of the snippet. We’ll name this "Show Alert Controller."
Then a summary, which is a short description. We’ll make this, "Returns a UIAlertController based off of the given title, and body text." That sounds like a good summary to me.
Then you have some other options. Language, Platform, Completion, and Availability. We are going to leave all of those at their defaults except completion.
The completion shortcut is what you will have to type to get the code snippet to show up. We’ll make this “salert.”
Then click on the “Done” Button. This will save your Code Snippet, and bring you back to your code.
Now if I type my completion shortcut which was "salert" it will autocomplete.
and that's it!
If you ever forget your completion shortcuts or want to modify or delete any of your snippets, you can click the little plus in the right hand corner. That will bring up your snippets library.
Check us out at our website for more content like this:
Text Version:
Hi and welcome back, today I'm going to be showing you how to create a code snippet
in Xcode 11.
As you can see I have a function here called showAlertController, I want to put this into a code snippet so I can use it easily in future projects.
I'm going to do that by highlighting all of the code that I want included in the snippet, then right clicking, and selecting "Create Code Snippet."
This should pop up a menu.
It's going to need a title, which will be the name of the snippet. We’ll name this "Show Alert Controller."
Then a summary, which is a short description. We’ll make this, "Returns a UIAlertController based off of the given title, and body text." That sounds like a good summary to me.
Then you have some other options. Language, Platform, Completion, and Availability. We are going to leave all of those at their defaults except completion.
The completion shortcut is what you will have to type to get the code snippet to show up. We’ll make this “salert.”
Then click on the “Done” Button. This will save your Code Snippet, and bring you back to your code.
Now if I type my completion shortcut which was "salert" it will autocomplete.
and that's it!
If you ever forget your completion shortcuts or want to modify or delete any of your snippets, you can click the little plus in the right hand corner. That will bring up your snippets library.