Xcode Objective-C Macros Cheatsheet For iPhone Programmers

By
On April 7, 2009

Xcode provides short keyboard abbreviations, or macros, to save you keystrokes. This is similar to the “snippet” functionality in the popular TextMate editor.

The built in set include common directives, declarations, flow control, loops and other common text patterns you’re likely to key-in while programming iPhone applications.

To use a macro, enter the abbreviation, hit escape, and select the expanded text.

While the canonical list of the dozens on built-in macros can can be found in Apple’s Xcode Workspace guide, I’ve always found having a printed cheatsheet handy helps me get to that magical point where they come naturally, without even thinking about them.

To that end, I’ve created a handy single-page PDF containing the 34 macros you’ll use most often, organized and categorized for easy lookup. Enjoy!

  • Chris Griffin

    In connection with those macros I have also changed some key definitions. First go to System Preferences > Keyboard & Mouse > Keyboard. Click on Modifier Keys… Change the Caps Lock to be the Control key (Who uses Caps Lock anyway?). Then do the opposite for the Control key. Next go to XCode > Preferences > Key Bindings > Menu Key Bindings. Open the Edit menu and scroll down until you see Next Completion. Define this as Control-; Then two spaces below that is Select Next Placeholder. Define that as Control-’ (single quote).
    Now you can hold the shift key down and type a ‘ to go to the next placeholder in method definitions. I find this much easier and fast than the default key assignments. Of course you can select different key to your taste.

  • Pingback: Makra (snippety) dla programistów iPhone | appledev.pl

  • http://howtomakeiphoneapps.com MattjDrake

    Nice, that is really cool. I would like to link back to this from my website. Think this is a great resource.

  • NicolasB

    Cool…

    There’s a bunch of them actually, one that I use all the time is csep : it extends to a “C-Separator” line like this :

    /*******************************/

    Very useful along some #pragma mark – (the macro for this one is pm by the way) to clean up a file organization by groups of methods.

  • Pingback: Amazing Xcode Tips Leave Developer In A State Of Shock | iPhone Development Tutorials and Programming Tips

  • Mike

    thanks for saying how to create the macros.