Sébastien FOCK CHOW THO

The Passioned Mobile Developer Interested Graphic Designer

How to use snippet with xCode

A SO's answer has shown up in the last recent update of Nissan Application: "Nissan app developer busted for copying code from Stack Overflow" This kind of error occurs often, especially when you are dealing with repetitive and onerous tasks, such as GPS data access authorization for example...

With the many websites and forums dealing with programming issues, it's easy to find an answer to any problem you can face, but copying an answer without understanding it isn't a good idea.

Even then you understood and resolved the issue you were facing, you'd rather rewriting the solution by yourself to avoid such a mistake.

Thanks to Apple developers, `xCode` provides you a wonderful tool to avoid rewriting repetitive tasks: the `code snippet library`

You can register your own snippets in this library and reuse them in all your projects by following these steps:

  1. Select the code you want to set as a snippet
  2. Open the `Code Snippet Library`
  3. Drag the selected code to the `Code Snippet Library`
  4. Edit the generated snippet and add a `completion shortcut`
  5. Start typing your shortcut in anywhere and `xCode` will provide the corresponding auto-completion.