- Creating New Projects
- Building Hello World the Template Way
- Using the Simulator
- The Minimalist Hello World
- Converting Interface Builder Files to Their Objective-C Equivalents
- Using the Debugger
- Memory Management
- Recipe: Using Instruments to Detect Leaks
- Recipe: Using Instruments to Monitor Cached Object Allocations
- Analyzing Your Code
- Building for the iOS Device
- Detecting Simulator Builds with Compile-Time Checks
- Performing Runtime Compatibility Checks
- Pragma Marks
- Preparing for Distribution
- Over-the-Air Ad Hoc Distribution
- Submitting to the App Store
Pragma marks organize your source code by adding bookmarks into the method list pop-up button at the top of each Xcode window. This list shows all the methods and functions available in the current document. Adding pragma marks lets you group related items together, as shown in Figure 3-22. By clicking these labels from the drop-down list, you can jump to a section of your file (for example, to Utility or RAOP) as well as to a specific method (such as -hexStringFromBytes:).
Figure 3-22. Use pragma marks to organize your method and function list.
To create a new bookmark, add a pragma mark definition to your code. To replicate the first group in Figure 3-22, for example, add the following:
#pragma mark Class
You can also add a separation line with a single dash. This uses a shortcut to add a spacer plus a mark:
#pragma mark –
#pragma mark – Marker Title
The marks have no functionality and otherwise do not affect your code. They are simply organizational tools you choose to use or not.
When you need to see more than one part of your code at once, Xcode lets you close and open method groups. Place your mouse in the gutter directly to the left of any method. A pair of disclosure triangles appears. Click a triangle, and Xcode collapses the code for that method, as shown in Figure 3-23. The ellipsis indicates the collapsed method. Click the disclosure triangle, and Xcode reveals the collapsed code. You can also collapse any compound statement.
Figure 3-23. Xcode lets you collapse individual methods and functions. This allows you to see parts of your program that normally would not fit onscreen together.