Handout-3-XcodeTipsTricks

Reviews
Shared by: Jim Zafrani
Stats
views:
349
rating:
10(1)
reviews:
0
posted:
1/22/2009
language:
English
pages:
0
CS193P Fall 2008 Handout #3 Doll/Marcos 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 them to memory, will pay back on the investment many times over. Here’s a list of the ones that I find most useful; I use all of these on a daily basis. I’ve listed the menu item (where one exists), default keyboard shortcut and a brief description Edit→Completion List: Option-Escape Pops up a popup list of recognized completions. The list is sensitive to where you’re typing. It will complete methods, instance variables, global variables, constants, struct members, etc. For example if you’ve just typed: “[myString setIn” Xcode will notice that , you’re calling a method on an NSString and only show you methods for the NSString class starting with “setIn” The list can be sorted strictly alphabetically or by “best . guess” (there’s a little icon in the popup list that lets you toggle). I run with mine set to “best guess” and that does a good job of guessing. While the list is up you can continue typing and it will narrow the result set. Use the up/down arrows to choose a different item and hit return or tab to select it. Edit→Next Completion: Control-period An alternative to the full-blown popup list is to simply use Next Completion to do an inline completion of the best guess. If you don’t get what you want the first time you can repeatedly invoke it to cycle through the completions. Edit→Select Next Placeholder: Control-forward slash When choosing a method that takes arguments via completion using one of the above methods you’ll see something like: [self setValue:<#(id)value#> forKey:<#(NSString *)key#> The “<#...#>” notation are called placeholders. By using the Select Next Placeholder shortcut you can quickly jump from one argument to the next. The logic here is pretty straightforward, Xcode just searches forward in the text file from where the insertion caret is looking for one of these blocks and then selects it. In this example I had typed “setVal” did a Next Completion which filled out the method and then doing , Select Next Placeholder it makes filling in the arguments really pretty quick. View→Switch to Header/Source File: Command-Option-Up arrow This keyboard shortcut is the same as the button on the header above the text area. It just jumps back and forth between the .h and .m (or .c, .cpp, etc) file. Jump to Implementation/Interface: Command-double click on text When you command-double click on a method name Xcode will try to jump to the method implementation (if it can find the source file containing it) or at least to the method interface. Unfortunately it doesn’t always get it right, notably when double clicking on a method that takes multiple arguments. This is also handy for double clicking on class names to jump straight to the header file for that class. Page 1 of 2 CS193P Fall 2008 Handout #3 Doll/Marcos Jump to Documentation: Option-double click on text Similar to the Jump to Implementation, option-double clicking on something will pop up the documentation window and try to find what you clicked on. If what you clicked on isn’t found then you’ll get an empty search result. Format→Re-Indent: No default keyboard shortcut Reindents the text that’s selected. There’s no default keyboard shortcut but you can add one (and change any of the above) in the Key Bindings Preference panel in the “Menu Key Bindings” tab. Personally I use command-shift-I (that’s an “eye”). File→Open Quickly: Command-Shift-D Pops up a panel where you can type a file name. This is most frequently used for opening header files from the Cocoa frameworks. You can type in a name without an extension and Xcode will first try to find an implementation file and if it can’t find one will look for an interface file. The text field is not case sensitive so you can type “nstableview” and it’ll find the right file. Preferences In a similar way to how the learning the key shortcuts above will make life easier for you, setting a couple preferences can improve your Xcode experience. Here’s a list of what I recommend: • • • In the Code Sense pref pane turn off the “Indicate when completions are available” It tends . to slow things down Also in the Code Sense pane, turn off the “Automatically suggest on member call / access” I . don’t recall if this is on by default or not but if it’s on it can be a frequent source of “spinning beachballs” in the Xcode editor. In Building, set the “Place Build Products in:” option to “Customized location:” and specify a directory that you can write into. This will keep all the build files outside of your source tree which makes submissions easier and keeps your source unpolluted. If you’re working on a LaIR machine you’ll probably have to set it to something like “~/build” although I’m not posi, tive how that will work. If this doesn’t work out, let me know. In Indentation, make sure “Syntax-aware indenting” is enabled. I check all the “Automatically indented characters:” feel free to check what works for you. • Page 2 of 2

premium docs
Other docs by Jim Zafrani
Handout-1-Syllabus
Views: 183  |  Downloads: 12
Handout-0-Overview
Views: 199  |  Downloads: 16
AssignmentPresence4
Views: 280  |  Downloads: 18
AssignmentPresence2
Views: 377  |  Downloads: 18
Assignment3
Views: 289  |  Downloads: 21
Assignment2B
Views: 123  |  Downloads: 10
Assignment2B-Walkthrough
Views: 302  |  Downloads: 16
Assignment2A
Views: 251  |  Downloads: 11
Assignment1B
Views: 530  |  Downloads: 8
Assignment1A
Views: 93  |  Downloads: 11
19-UnitTestRuntimeLoc
Views: 133  |  Downloads: 26
19-UnitTestRuntimeLoc_2_
Views: 68  |  Downloads: 23
18-DeviceAPIs
Views: 416  |  Downloads: 30
17-BonjourAndStreams
Views: 637  |  Downloads: 31
16-OpenGLBasicsAndPVR
Views: 158  |  Downloads: 28