Alex Rivera | Logout

Hidden Features of Xcode

Asked 2008-09-28T17:26:37.763
338

With a huge influx of newbies to Xcode, I'm sure there are lots of Xcode tips and tricks to be shared.

What are yours?

Edit
Report

14 Answers

341

Switch to Header/Source File

  • 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 ↑
answered 2008-09-28T21:15:38.367
66

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

answered 2008-10-02T10:57:09.710
50

⌘-[ and ⌘-] to indent and unindent selected text. Makes cleaning up source code much easier.

answered 2008-11-08T22:31:28.327
43

Hold Option while splitting windows to split vertically rather than horizontally.

answered 2009-03-31T15:21:22.730
26

Navigate among open files back and forth:
⌥⌘←
⌥⌘→

answered 2008-10-01T16:30:27.513
25

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!

answered 2009-05-16T07:57:12.497
16

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.

answered 2010-08-18T04:07:32.490
13

ctrl + alt + ⌘ + r to clear the log

answered 2008-12-03T01:42:31.843
12

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.

answered 2008-10-01T18:18:54.040
12

Use the Class Browser to show inherited methods

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.

answered 2008-10-22T18:21:47.303
9

Recompile-free debug logging

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.

TODO comments

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!
answered 2009-09-04T05:52:13.770
6

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.

answered 2008-09-29T17:15:34.023
6

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.

answered 2010-09-16T15:33:41.490
5

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.

answered 2010-08-11T09:22:11.073

Your Answer