Cocoa in the Shell

by Nyx0uf

Xcode 4 Code Snippets Library

Aug 04, 2010

With Xcode 4 Apple introduced very cool stuff, one I love is the Code Snippet Library. As its name suggests, it's a library with some snippets of code. What's cool is that you can add your own snippets and define a shortcut to it.

XCode 4 Snippets Library

For example when I work with iPhone SDK I often use the networkActivityIndicatorVisible property of UIApplication, so I created a snippet with shortcut netwa, which writes for me :

XCode 4 Snippets Library
XCode 4 Snippets Library

If like me you want to set a placeholder for an argument, you simply write it this way :

[UIApplication sharedApplication].networkActivityIndicatorVisible = <#state#>;

It will automatically create a token field for your argument (like on the last screenshot).
It's very convenient when you create snippets with several arguments because it allows to switch to them with the tab key.