Tips & Tricks for a Happier Xcode Existence
Keyboard Shortcuts There are a number of keyboard shortcuts in Xcode which, if you take the time to commit themto memory, will pay back on the investment many times over. Here’s a list of the ones that I findmost useful; I use all of these on a daily basis. I’ve listed the menu item (where one exists), de-fault keyboard shortcut and a brief description
: Option-EscapePops up a popup list of recognized completions. The list is sensitive to where you’retyping. It will complete methods, instance variables, global variables, constants, structmembers, etc. For example if you’ve just typed: “[myString setIn”, Xcode will notice thatyou’re calling a method on an NSString and only show you methods for the NSStringclass starting with “setIn”. The list can be sorted strictly alphabetically or by “bestguess” (there’s a little icon in the popup list that lets you toggle). I run with mine setto “best guess” and that does a good job of guessing. While the list is up you can con-tinue typing and it will narrow the result set. Use the up/down arrows to choose adifferent item and hit return or tab to select it.
: Control-periodAn alternative to the full-blown popup list is to simply use Next Completion to do aninline completion of the best guess. If you don’t get what you want the first time youcan repeatedly invoke it to cycle through the completions.
Select Next Placeholder
: Control-forward slashWhen choosing a method that takes arguments via completion using one of theabove methods you’ll see something like:
[selfsetValue:<#(id)value#> forKey:<#(NSString *)key#>
The “<#...#>” notation are called placeholders. By using the Select Next Placeholdershortcut you can quickly jump from one argument to the next. The logic here ispretty straightforward, Xcode just searches forward in the text file from where the in-sertion caret is looking for one of these blocks and then selects it. In this example Ihad typed “setVal”, did a Next Completion which filled out the method and then doingSelect Next Placeholder it makes filling in the arguments really pretty quick.
Switch to Header/Source File
: Command-Option-Up arrowThis keyboard shortcut is the same as the button on the header above the textarea. It just jumps back and forth between the .h and .m (or .c, .cpp, etc) file.
Jump to Implementation/Interface
: Command-double click on textWhen you command-double click on a method name Xcode will try to jump to themethod implementation (if it can find the source file containing it) or at least to themethod interface. Unfortunately it doesn’t always get it right, notably when doubleclicking on a method that takes multiple arguments. This is also handy for doubleclicking on class names to jump straight to the header file for that class.CS193P Handout #3Fall 2008 Doll/MarcosPage 1 of 2