xcode使用小技巧

1. 更改公司名称 (Changing the Company Name )
改变公司名称, 当你用Xcode新建一 Objective C 源文件的时候, 通常Xcode会自动生成底下的注释:
//
// TapDance.h
// Groovilicous
//
// Created by markd on 7/25/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//

markd 是你登录Mac系统的名字
__MyCompanyName__ 是你定义的公司名字, 可以通过以下命令在Terminal里面进行修改名字:

defaults write com.apple.Xcode PBXCustomTemplateMacroDe finitions '{"ORGANIZATIONNAME" = "Length-O- Words.com";}'

Length-O- Words.com就是定义新的公司名称, 你可以自己替换自己要定义的名称.

2. Writing Your Code with a Little Help from Xcode
缩进
先选择一段要编辑的内容,用鼠标拖动选择好后:
Command(win键盘的Alt) + [       左缩进
Command + ] 右缩进
右键 -> Re-Indent Selection 自动编排格式

代码自动完成
Xcode会记住很多已经存在的名字, 你键入字符的时候, 它会根据自己的字典来猜测你要写的内容, 如果匹配成功, 直接敲Tab键或者回车键Xcode就帮你完成剩余的内容. Escape会列出一个下拉列表, 让你自己有更多的选择. ctrl+/ 来定位函数的多个占位符参数.

Kissing the Parentheses (括号配对)
Xcode 可以自动配对括号, 而且回自动高亮显示.
Double click one of the delimeters(")", "]", "}"), and Xcode will select the code between it and its mate.

Mass Edit(批量编辑)
1. 快照(Snapshot)
File -> Make Snapshot 建立快照
File -> Snapshots                   打开快照管理器, 可以恢复之前建立的快照.

2. 查找(Find)
Edit -> Find

3. 编辑在作用域中同名变量(Edit all in Scope)
选择要编辑的名称
Edit -> Edit all in Scope

4. 重构(Refactor)
当你重命名一个类的名字的时候, 相应的文件名也被Rename. 这个功能很好用. Eclipse 有这种功能, VC的VA插件也有, 不过好像它们都不能重名文件名.

选择要重命名的类名, 函数名等
Edit -> Refactor

注释: 很多命令有快捷键, 可以利用快捷键加快效率, 没用快捷键的, 可以在Perferences里的key buildings设置命令对应的快捷键.

5. Navigating Around in Your Code
下面的快捷键不仅仅是适用于Xcode, 而且适用诸如TextEdit, Safari's URL bar 等等, 一般具有编辑功能的都有这张功能(在Mac中)
ctrl + A       将光标移动到当前光标所在行的开始位置
ctrl + E       将光标移动到当前光标所在行的结束位置
ctrl + T       交换当前光标所在为止的词和此词的上一个词的位置.(就是互换俩个词)
ctrl + K      删除当前光标所在位置到当前行结尾处
ctrl + D       相当于键盘的Delete按键, 删除后面一个字符.

6. 书签(Bookmarks)
Edit -> Add Bookmarks (Alt + D)
In the Groups & Files pane,     你能找到Bookmarks, 里面的你可以点击.


Xcode Keyboard Shortcuts
? 表示: Command(Alt)
?表示: Shift
? 表示: Win
Control表示:Ctrl
Keystroke                                        Description
??E                                                      Expand the editor
?[                                                                Shift the code block to the left
?]                                                                 Shift the code block to the right
Tab                                                             Accept a completion
Esc                                                          Show the completion menu
Control-.                                           (period) Cycle through the completions
Shift-control-.                             (period) Cycle backward through the completions
Control-/                                          Move to the next completion placeholder
Command-control-S      Make a snapshot
Control-F                                     Move the cursor forward
Control-B                                        Move the cursor backward
Control-P                                 Move the cursor to the previous line
Control-N                                 Move the cursor to the next line
Control-A                                         Move the cursor to the beginning of the line
Control-E                                 Move the cursor to the end of the line
Control-T                                 Transpose the characters adjacent to the cursor
Control-D                                Delete the character to the right of the cursor
Control-K                                Delete the line
Control-L                                Center the cursor in the text editor
??D                                                 Show the Open Quickly window
??↑                                                               Open the counterpart file
?D                                                               Add a bookmark
Option–double-click                                Search in documentation
?Y                                                               Run the program with the debugger
??P                                                               Continue (in the debugger)
??O                                                               Step over
??I                                                               Step into
??T                                                               Step out