How to Navigate the Xcode Source Editors for iOS App Development

By Jesse Feiler

Most iOS app 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 one or more optional Assistant panes that show related content.

If you select an interface [.h] header file, the Assistant pane can automatically show the corresponding implementation [.m] code file, and vice versa; showing the Version pane is also an option.

The term pane (Standard editor pane and Assistant pane) used it to refer to certain configurations. This distinguishes 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.

  • Core Data Model editor: If you use Core Data, you can design your data model for tables and relationships graphically. The Core Data Model editor also can convert your graphical representation of your data model to Objective-C code. The Core Data model editor is definitely worth exploring.

  • 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.

So far, you’ve worked 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, in 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).

Because MasterViewController.m was 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.) The Assistant was also selected in the Editor selector and split the panes using the split controls (“+” icon at the far right in the Jump bar).

A open app project in Xcode

Notice that when the Assistant was selected, the MasterViewController.h file opened.

Xcode's assistant editor icon.

That’s because the Assistant editor pane automatically (depending how you have set it) shows the related content for whatever is selected in the Project navigator so that you can edit both easily. You then see MasterViewController.m (the implementation code file) in the Standard source editor pane and MasterViewController.h (the header file) in the Assistant editor pane.

Clicking the split control (the + at the right of the jump bar) opens a second pane in the Assistant editor pane as well, giving you a total of three panes.

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)

  • Declared properties

In recent updates to Xcode and the sample code on developer.apple.com, Apple has rejiggered the world of variables and properties with regard to classes. Declared properties are preferred to instance variables because they can contain more information than just the type and name of a variable and because their accessors can further encapsulate the data.

However, instance variables rather than properties are often more appropriate for scalars such as ints and floats. In addition, declaring instance variables as well as properties in a class extension in the implementation file further keeps them out of the way so that they are not visible to other classes.

The implementation (.m) code file, on the other hand, contains the code for the class, which includes each method definition. It also can contain a class extension with instance variable and property 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 Editor and then choose a layout. If the header file doesn’t appear for you, navigate to it using the Jump bar.