Code Snippets on Xcode – How to call your most used methods quickly

Code snippets let you call your methods with typing 3 or 4 characters. They are most likely short cuts which you can customize contents as you wish and Xcode lets you to add your custom method calling shortcuts.

Xcode also have some basic code snippets. For example, If you type “typedef” for defining a enumaration, Xcode offers code snippets automatically.

Screen Shot 2015-10-25 at 17.40.54

When you finish your most used code. Drag and drop your method call frame to Snippet Library. Select View > Utilities > Show Code Snippet Library to open Code Snippet Library.

Screen Shot 2015-10-25 at 17.35.38

Our example method is findMidPoint. After finishing method implementation, In viewDidLoad method, write sample method call, drag and drop to Code Snippet Library.

Screen Shot 2015-10-25 at 18.50.36

You can add completion shortcut, edit scope and change your snippet’s name.

Screen Shot 2015-10-25 at 18.52.04

After 3 or 4 characters typing, you’ll reach your method call short-cuts.

Screen Shot 2015-10-25 at 19.13.28

Happy coding.

PS: If you find this article useful please use like button 🙂 and if you have a question or a comment, don’t hesitate to share it!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s