Required documents for beginners: Xcode getting started tutorial (1)

Source: Internet
Author: User

Xcode is a powerful IDE development environment, just like VS2005 is required when you write a Windows program.XcodeProvides an environment for writing Mac programs. Therefore, if you want to become a developer of Mac programs, you can use them flexibly.XcodeTools are the first step you must do.

We often write programs at the sourceFileAdd the copyright statement and the company name in the header of; andXcodeIn the createFileWe have already done most of the work for us. We may need to modify the company name, becauseXcodeIf you don't know the name of our company, it's impossible to predict everything, so we need to set it for ourselves. How can we achieve this? BecauseXcodeThere is no placeholder for company name, so we must use terminal to set it.

Before using this command, let's take a look at the default file header annotations that xcode provides for us:

 
 
  1. //  
  2. //  untitled.m  
  3. //  FilesOrganize  
  4. //  
  5. //  Created by yan li on 8/29/09.  
  6. //  Copyright 2009 __MyCompanyName__. All rights reserved.  
  7. // 

Run the following command in terminal to open the hotkey of terminal: command + shift + U ):

 
 
  1. yan-lis-macbook-pro:~ yanli$ defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{"ORGANIZATIONNAME" = "LiYanzhong";}' 

Note that the preceding command is the same line in the terminal command line, rather than the two lines, because the command is too long. Note that no prompt will be sent when the command is executed, even if you have written an error in the command and executed the parameter name, no prompt will be sent, so if you execute this command and find that the expected effect does not appear, check whether you have a spelling error. After executing this command, restart xcode and recreate the file, note the file header created at this time, as shown in the following figure:

 
 
  1. /*  
  2.  *  untitled.h  
  3.  *  Untitled  
  4.  *  
  5.  *  Created by yan li on 8/29/09.  
  6.  *  Copyright 2009 LiYanzhong. All rights reserved.  
  7.  *  
  8.  */ 

1. Editor skills

How do I close the browser window on the Xcode interface?

Click inXcodeThe rightmost Editor icon on the toolbar, which can be opened or closed.XcodeSearch for projectsFile.Shortcut KeyIs command + shift + E.

If you use an icon in your window, you need to manually place it on the toolbar. How to put it?

Activate Xcode and go to View> Customize Toolbar... you will find many tools that do not appear on the toolbar on the right. You can drag the tools you want to use at any time to the toolbar.

2. How do I indent the first line of code?

Method 1: select the code to be indented, press the control key, click the cursor, pop menu appears, and then select Re-indent selection.

Method 2: select the code to be adjusted and press command + [move code left) or command +] Move code right ).

Powerful application with Automatic Code Completion

When writing code in Xcode, The Xcode editor often provides prompts. If the code prompts meet our requirements, we can press the tab key to select the prompted code.

If the prompt Code does not meet our requirements, we can press the esc key to display the entire prompt list and find what we need. There is a small box on the far left of the List Members. If f is in it, the corresponding member is a function; if m is in it, it is a method; if it is #, It is a # define command; if it is E, it indicates enumeration; if it is C, it indicates class.

You can useShortcut KeyControl +. loop between options; you can also use shift + control +. Reverse loop between options.

We can use the "Automatic Code Completion function" to query the APIs (interface methods) provided by a class ). The method is to write the class in the method call expression to implement this query function:

[NSDictionary + space, and then press the esc key to display the list of methods provided in NSDictionary. Note: [NSDictonary must be followed by spaces, prompting that the name of the Compiler class has been written. Next, enter the message, that is, the method name in the class ).

The shortcut to jump the cursor from a placeholder to the next placeholder is: control +/

When modifying the code of a project, take a snapshot first.

File-> Make Snapshot takes a Snapshot of the project; File-> Snapshots recovers from the Snapshot.

Corresponding Shortcut Keys: control + command + S; no shortcut keys for recovery

The advantage is that when the code is modified badly, the code can be restored to its most normal state.

It can be seen that this function only provides help when we modify the code, and cannot replace the manual modification of the Code.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.