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:
- //
- // untitled.m
- // FilesOrganize
- //
- // Created by yan li on 8/29/09.
- // Copyright 2009 __MyCompanyName__. All rights reserved.
- //
Run the following command in terminal to open the hotkey of terminal: command + shift + U ):
- 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:
- /*
- * untitled.h
- * Untitled
- *
- * Created by yan li on 8/29/09.
- * Copyright 2009 LiYanzhong. All rights reserved.
- *
- */
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.