Navigate in the Xcode Source Editors

When you create apps for iOS6, you need to understand the Xcode Workspace, including Assistant as well. This article will help you extend that knowledge and describe common tasks you need to be able to do in Xcode.

As you’ve seen, most development work in Xcode is done in the Editor area, the main area that's always visible within the Workspace window. The Editor area can also be further configured, with the Standard editor pane always shown, as well as an optional Assistant pane that shows related content. (If you select an interface [.h] header file, the Assistant pane shows the corresponding implementation [.m] code file, and vice versa; I don’t talk about the Version pane, but showing that area is also an option.)

The term pane (Standard editor pane and Assistant pane) here refers to certain configurations, even though Apple doesn’t use that term. This is to distinguish between the Editor area configuration (the Standard editor isn't actually an editor at all, but simply a single pane configuration in the editor area) and the built-in editors — an editor operates in an Editor area. The main editors are the following:

  • Source editor: You use this editor to write and edit your source code, as well as to set and enable (or disable, for that matter) breakpoints as well as to control program execution.

  • Project editor: With this editor, you view and edit project and target settings, such as build options, target architectures, and code signing characteristics.

  • Interface Builder: Here, you graphically create and edit user interface files in storyboards and .xib files.

The editor you use is determined by what you have selected in the Project navigator. An editor pane appears for that (selected) item in the Editor area.

In the beginning of a project, for storyboarding, you work primarily in the Interface Builder editor; but when you code, you do the bulk of your work in the source editor in the Standard editor pane, with some forays, as needed, into the Assistant editor pane and an occasional excursion into the Utility area as well.

You use the View selector in the Workspace toolbar to hide or show the Navigator, Debug, and Utility areas. If you like, you can hide the other areas and see just the source editor (and perhaps the Assistant).

This figure shows the Project navigator. Because RTMasterViewController.m has been selected, you see the source editor displaying that file in the Standard editor pane. (If you were to select one of the storyboard files in the Project navigator, you’d see Interface Builder as your editor of choice.)

In the figure, the developer has also selected the Assistant in the Editor selector and split the panes using the split controls (the next to the last “+” icon on the right in the Jump bar).

The source editor with Standard and Assistant editor panes.
The source editor with Standard and Assistant editor panes.

Notice that when the Assistant is selected, the RTMasterViewController.h file opened. That’s because the Assistant editor pane automatically (depending how you have set it) shows the related content for whatever you select in the Project navigator so that you can edit both easily. You then see RTMasterViewController.m (the implementation code file) in the Standard source editor pane and RTMasterViewController.h (the header file) in the Assistant editor pane. Clicking the split controls opens a second pane as well.

image1.jpg

The Standard editor pane (the left editor pane, or the top one if you have a horizontal split) is the one that’s affected by changing your selection in the Project navigator.

The interface (.h) header file defines the class’s interface by specifying the following:

  • The class declaration (and what it inherits from).

  • Methods.

  • Any instance variables (that is, variables defined in a class). Note that Apple has suggested moving away from declaring instance variables in the interface and moving those declarations to the implementation file to keep them more private.

The implementation (.m) code file, on the other hand, contains the code for the class, which includes each method definition. It also can contain the instance variable declarations.

By default, the Assistant editor pane appears to the right of the source editor pane. To change the orientation of the Assistant editor pane to the source editor pane, choose View→Assistant Layout and then choose a layout. If the header file doesn’t appear for you, navigate to it using the Jump bar, as explained in the next section.

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement

Inside Dummies.com