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!

0 responses to “Xcode Objective-C Macros Cheatsheet For iPhone Programmers”

  1. Chris Griffin says:

    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.

  2. MattjDrake says:

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

  3. NicolasB says:

    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.

  4. Mike says:

    thanks for saying how to create the macros.