Information Technology Reference
In-Depth Information
Completion scope. You can control how widely Xcode searches when looking for completion matches.
The default is Function or Method.
Snippets often need placeholder tokens, which can be filled in later when you use the snippet. For example
when creating an alert, you can use a placeholder for the message text.
To create placeholder tokens, type the following:
<#placeholderName#>
The placeHolder name string is arbitrary and doesn't have to be unique. It appears in the snippet code as a
highlighted placeholder, and you can edit it and tab over it in the usual Code Completion way.
In the figure, the snippet includes two placeholders: <#title#> and <#message#> . The choice of the
number and placing of the placeholders is up to you. Optionally, you can create different versions of the same
snippet with different placeholders; for example, you can create one for an alert that uses standard text and an-
other in which the labels are placeholders and can be filled in as needed.
NOTE
The snippet feature in Xcode doesn't support open development; there's no way to share snippets across a team or
make them available online. Public alternatives are available, such as snipt at http://snipt.net and Willow at ht-
tp://wingsforpigs.com/Willow/Willow.html . Public snippet sharing may not be ideal for your project, but it can be
a useful option to explore, especially for scripted languages such as Python and Ruby.
Jumping to a Definition
It's often useful to jump to a method signature or symbol definition. You can find definitions by searching for
them, but it's much quicker to use the Jump to Definition feature.
To use it, highlight a symbol, right-click to show the contextual menu, and select the Jump to Definition option.
If there's a single definition, Xcode displays it in the main code window. Note that the definition may be in one
of the Cocoa or Cocoa Touch header files, and not in your code—in which case you'll see a method signature,
and perhaps some supporting comments from Apple.
If there are multiple definitions—for example, when there are multiple classes with dealloc methods—Xcode
displays a new menu with a list of definitions. You can select one to view it.
Note that definitions don't appear in the Assistant window when it's open—they take you away from your ori-
ginal editing location into a different file, or a different part of the same file. To move back to the original loca-
tion, use the back arrow at the top left of the edit window.
Summary
 
Search WWH ::




Custom Search