Option ⌥ Command ⌘ Up Arrow ↑
View > Switch to Header/Source File
Switches between the .m and .h files.
- In Xcode 4 this is ctrl Command ⌘ Up Arrow ↑
Get Colin Wheeler's Complete Xcode Keyboard Shortcut List (available as PDF or PNG). Print it and keep it somewhere visible (I've got it on the wall next to my screen).
edit: Updated versions for Xcode 3.2
edit 2: Updated versions for Xcode 4
⌘-[ and ⌘-] to indent and unindent selected text. Makes cleaning up source code much easier.
Hold Option while splitting windows to split vertically rather than horizontally.
Navigate among open files back and forth:
⌥⌘←
⌥⌘→
Technically an Interface Builder tip, but they're a book-matched pair, so I don't think this is off topic...
Shift + Right Click on one of your controls and you get a nice pick list of the object hierarchy. No more click, click, click, frustration!
Being able to quickly see all the methods that can be overriden from a super class. For example when extending UITableViewController I just type in my implementation:
- ta
and then I hit ESC to see all the methods from my superclass that begin with "ta" such as
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
This also works when adopting protocols.
ctrl + alt + ⌘ + r to clear the log
Might go without saying, but if you want to use intra-word navigation, make sure you change the key presets in for Spaces (in the Expose & Spaces preference pane), if you use it.
I switched Spaces to use Ctrl-Option Left/Right.
Edit: To set Spaces to Ctrl-Option Left/Right, select the "To switch between spaces:" popup and hold down the Option key. The first item will change from Ctrl Arrow Keys to Ctrl-Option Arrow Keys.
Apple's API reference documentation does not show methods inherited from a superclass. Sometimes, though. it's useful to be able to see the full range of functionality available for a class -- including a custom class of your own. You can use the Class Browser (from the Project menu) to display a flat or hierarchical list of all the classes related to a current project. The upper pane on the right hand side of the browser window shows a list of methods associated with the object selected in the browser. You can use the Configure Options sheet to select "Show Inherited Members" to show inherited methods as well as those defined by the selected class itself. You click the small book symbol to go to the corresponding documentation.
cdespinosa's answer to Stack Overflow question How do I debug with NSLog(@“Inside of the iPhone Simulator”)? gives a method for a debugging-via-logging technique that requires no recompilation of source. An amazing trick that keeps code free of debugging cruft, has a quick turnaround, and would have saved me countless headaches had I known about it earlier.
Prefixing a comment with TODO: will cause it to show up in the function "shortcut" dropdown menu, a la:
int* p(0); // TODO: initialize me!
When you use code completion on a method and it has multiple arguments, using CTRL + / to move to the next argument you need to fill in.
Xcode code formatting... is one of the thing you need when you want to make your code readable and look good.
You can do the code formatting by yourself or save some time using scripts.
One good way is.. use Uncrustify. It is explained in Code Formatting in Xcode.
Select a block of text and use
Command + '/'
To comment out the block of text. Selected the commented block and use the same shortcut to uncomment it.