The editor area

The editor area is the main area of the Xcode workspace and the area in which you will be spending the majority of your time. It will display your code, your interfaces, device previews, and so on. At the top, you will find the jump bar, a specialized toolbar that allows you to quickly jump to specific methods and properties within the current file, or to quickly move to other files within your project. The rightmost area of the jump bar will show whether there are any warnings or errors in your project:

The editor area

The jump bar

There are several editors available for you within the editor area. They can be chosen using the editor buttons in the toolbar. You can choose the Standard editor, the Assistant editor, or comparison editor.

The Standard editor

Xcode Standard editor is a powerful and full-featured code editor with many advanced features. A few of these features are as follows:

  • Syntax highlighting: Xcode highlights variables, constants, strings, and objects differently in order to improve readability. This helps you spot errors and you are able to quickly scan and understand your code.
  • Code folding: This feature helps you hide long function declarations by collapsing them into a short vertical space. It is helpful when smaller screen resolutions are used.
  • Contextual help: Holding down the Opt key while hovering your mouse over the declaration of an object will turn your cursor into a question mark. Clicking with your mouse will open a pop-up window that shows you information about the object with the option to see more information at the bottom. This is helpful for quick checking of the documentation for any object.
  • Context jump: Holding down the Cmd key and clicking on any object, method, property, or function will jump to its point of declaration, regardless of the location of the said declaration. This is extremely helpful for tracing the flow of a program as well as learning how a feature is implemented.
  • Fix-it: As you write code in the Standard editor, Xcode analyzes it and will notify you of any warnings or errors that have been created. Some examples are catching when declared variables aren't used, object type mismatches, and missing declarations or misspelled variable names. This cuts down the amount of time spent in building and running your app.
  • Code completion: Because of Xcode's deep knowledge of Swift, Objective-C, and the Cocoa API, it is able to suggest a completion for code that you have only started to write. If you type in a few letters of a function name, Xcode will show you a pop-up list of possible options so as to complete it for you. When selecting a completion, it will complete the code and add in any token placeholders as needed, which can be replaced quickly and easily by pressing the Tab key.

Tip

You can invoke code completion at any time by pressing Esc or Ctrl.

The Assistant editor

The Assistant editor is used to show counterparts and files related to the file that is currently open in the primary editor. For example, you will use this editor to view your Interface Builder files and their associated view controller in order to connect outlets and actions (this is covered in detail in Chapter 4, Interface Builder). Similar to the standard editor, there is a jump bar available in any Assistant editor windows in order to allow quick movement around your project.

Alternatively, when opening a file to edit from the project navigator, you can hold down Opt + Shift on the keyboard while selecting the file for editing. This will show an interactive Assistant editor dialog box, which will let you select where to open the file.

You have the option to open the file in the primary window, split the primary window and open the file side by side in the Assistant editor, or further split the Assistant editor window to show more files at once.

The Assistant editor

The Assistant editor dialog box

Tip

A quick way to open a file is by using the Open Quickly keyboard shortcut Cmd + Shift + O. This displays a textbox in which you can type a filename, class, method, or property that the system will open for you.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.23.101.60