XCode Snippets { }

ValOsip
iOS Blogs
Published in
2 min readJul 15, 2015

While learning learning Objective C, I found myself copying and pasting blocks of code either from my lecture notes or stackoverflow.

(Core Data, Blocks, NSURL, etc…)

Even with XCodes autocompletion and FuzzyAutocomplete, I found that I was retyping blocks of code countless times each day.

Xcodes snippets offer a good solution for a user to add their own custom snippets to use across all of their projects.

The best part is that its super simple.

  1. Creating a new snippet:

Type a line or block of code, highlight it and drag it into the Code Snippet Library:

2. Edit the newly created snippet

3. Use the snippet in your code:

You can either search the Code Snippet Library for your newly created snippet and drag and drop it into your code OR if you set a “Completion Shortcut” then you can type that shortcut inside your code.

4. Share snippets between your macs or with your friends

Navigate to your CodeSnippet Folder through the terminal:

~/Library/Developer/Xcode/UserData/CodeSnippets/

To clean it up a bit, you can rename the snippets.

--

--