Using the Xcode Text Editor
The main tool you use to write code for an iPad application is the Xcode Text editor. Apple has gone out of its way to make the Text editor as user-friendly as possible, as evidenced by the following list of (quite convenient) features:
- Code Sense: Code Sense is a feature of the editor that shows arguments, placeholders, and suggested code as you type statements. Code Sense can be really useful, especially if you're like me and forget exactly what the arguments are for a function. When Code Sense is active (it is by default), Xcode uses the text you typed, as well as the context within which you typed it, to provide suggestions for completing what it thinks you're going to type. You can accept suggestions by pressing Tab or Return. You may also display a list of completions by pressing the Escape key. You can set options for code sensing by choosing Xcode → Preferences and clicking the Code Sense tab.
- Code Folding in the Focus ribbon: With Code Folding, you can collapse code that you're not working on and display only the code that requires your attention. You do this by clicking in the Focus Ribbon column to the left of the code you want to hide to show a disclosure triangle. Clicking the disclosure triangle hides or shows blocks of code. (Not sure where the Focus Ribbon column is? Look right there between the gutter, which displays line numbers and breakpoints, and the editor.)
- Switching between header and implementation windows: On the toolbar above the Text editor, click the last icon before the lock to switch from the .h (header) file to the .m (implementation) file, and vice versa. While the header declares the class's instance variables and methods, the implementation holds the logic of your code. If you look inside the Classes section of the Groups & Files list of the Project window, you can see the separate .h and .m files for the DeepThoughtsAppDelegate and DeepThoughtsViewController view classes.
- Opening a file in a separate window: Double-click the filename to open the file in a new window. If you have a big monitor, or multiple monitors, this new window enables you to look at more than one file at a time. You can, for example, look at the method of one class and the method it invokes in the same class or even a different class.