Learning on the fly inside XCode

XCode has a feature called Research Assistant, a little window that gives you helpful details about the code under your text cursor. As your text cursor moves, Research Assistant provides a sort of running commentary about whatever the text cursor is pointing at. It tells you where a keyword or message was defined, and a short blurb about what it does. Not all pieces of code have associated documentation, so sometimes the window is blank. Blue underlined keywords act as clickable hyperlinks to full documentation. It’s a great tool for exploring code with the text cursor, or as you type with code sense enabled.

Research Assistant for text cursor pointing at "initWithFrame:"

Research Assistant for text cursor pointing at "initWithFrame:"

You can turn on Research Assistant by choosing Help > Show Research Assistant from the menu, or by pressing the Control+Shift+/ key combination. Research Assistant works even better in combination with Code Sense and other XCode features that help you learn on the fly.

Use the built-in Doc Sets and quick reference shortcuts in XCode to help you explore code samples. Once you start XCode, download the iPhone OS Doc Set. Open the documentation window through the Help > Documentation menu, and then press “Get” on the doc sets you want to download. Now you can hold down the Option key and double-click on words in the source code to jump directly to the full documentation! You can also hold down the Command key and double-click on classes and methods to jump directly to their definitions in the original header file.

Make sure the Documentation Window has filters optimized for source code referencing. I have my filters set to API / iPhone OS 2.2 Library / All Languages / Exact. You need to include “all languages” in the filter because some essential frameworks like Core Graphics are written in pure C, not Objective-C.

Check out this page of XCode tips for more useful tricks. XCode also supports many emacs key combos. Here are a few useful XCode shortcuts I use when exploring sample code:

Option+Command-LeftArrow = go to previous source file.
Option+Command-UpArrow = toggle between header and implementation file.
Shift+Command+/ = search available commands and display the associated menu item

One Response to “Learning on the fly inside XCode”

  1. [...] XCode’s usually the best place to get help (check out my earlier post about learning on the fly inside xcode) [...]

Leave a Reply