
摘自:http://www.cocoachina.com/newbie/env/2014/0127/7766.html

感谢论坛成员郭亚鑫的热心翻译。
在iOS开发中,Xcode 是最使用最多的IDE。苹果公司在其更新和增加产品功能做了大量工作。知道如何充分利用它的功能可以帮你更快更有效地编码。看看下面的关于Xcode5的快捷键和小提示
Xcode的工作窗口主要分为5个区域:工具栏,导航栏,编辑区,调试区,实用工具区。

Xcode导航栏
导航区域也有一个工具条。它包含8个选项:工程导航器,符号导航器,搜索导航器,问题导航器,测试导航器,调试导航器,断点导航器和日志导航器。你可以通过按? 键和相应的索引来选择它们中的一个。









当你需要额外的空间或者解除导航器,你可以实用
(command + 0);

在导航区域的底部有导航过滤器。每一个选项的过滤器都是不同而且非常有用。在工程导航器选项下的过滤器允许你查看最近修改和编辑的文件。
最近修改可以使你注意你的SCM改变。

如果你知道你查找文件的名字你可以输入一些文字来过滤文件。然而,更好地使用文件过滤器是使用快捷键。键盘的快捷键是:
可以快速打开。


这种做法非常便利和明智。即使你不知道想要搜索的文件或类的全名,这种方法仍可以帮你找到你想要的东西。

我不必拼写出全部单词(这就是当写视图控制器的时候只需写几个单词的原因)仍然能找到我想要的。
如果你想打开文件并找到246行(那是方法所在行数),你只需在快速窗口中添加:246即可。按着
(Go to line)输入行数就可以跳到其他行。


显示行数
如果想在Xcode5中显示行数,只需简单的同事按下cmd和",",设置窗口就会弹出。在此窗口中顶部选项点击Text Editing ,确保显示的检查框中的显示行数被勾选。

另一个非常有用的键盘快捷键:允许你在.h和.m文件之际相互转换。

返回先前的文件的快捷键是:
,进入下一个文件:


编辑
当你在编写代码的时候,可能命名的实例变量不符合它的意思或者拼写错误。你想要重新命名这个变量的所有实例,当然只在确定的范围。选择实例中的一个然后点击:
(Edit all in scope)你就会看到这个变量出现的地方有盒子围绕着它。编辑其中一个,就会更新其他所有的。对于代码的清理和重构是非常有用的方法。

另外对于代码重构非常有用的方法是行移动。想要这样做你可以:
(向上移动行)
(向下移动行)。


上下移动行的时候痕迹会被固定。
但是仍有代码有一些不合适的缩进,可以使用快捷键:
(重新缩排代码)。

如果你想自动缩进一段代码块儿,查看这里:Auto-Indent Lines of code in Xcode.
如果你想注释一些东西只需按下:
Comment/uncomment line or selection

除了标准的编辑器Xcode外,还有帮助编辑器和版本编辑器。为了从一个编辑器切换到另外一个你可以使用下面的快捷键:



帮助编辑器对于辅助内容非常优秀。它追踪主编译器的内容。当你在编写代码的时候想要查看此类的父类的时候,只需切换到帮助编辑器即可。你回看到副本,调用者或者测试者,包含信息以及更多内容。它非常强大,我建议你使用它。如果你想要打开帮助编辑器,只需按下option键
:
(打开帮助编辑器)


调试
通常情况下我们通过点击文档区域边栏设置和移除断点。你也可以通过键盘快捷键操作:
Add/remove breakpoint at current line。

在断点导航器可以查看存在的所有断点。显示断点导航器按下:



测试
使用
运行工程中所有的测试例子,或者使用
测试而无需building


在你运行测试例子时测试编辑器是你最好的朋友。按下?5可以显示测试编辑器。点击旁边的小按钮可以运行一个测试例子(完整测试)

通过过滤结果查看失败测试:

你可以使用增加异常断点相同的方法,来增加一个失败的测试断点,
资源控制

界面构建器

iPhone 模拟器

总结
如果你对发现Xcode更多特色感兴趣,我强烈推荐你看:WWDC sessions
Xcode Core Concepts – 401
From Zero to App Store in Xcode 5 – 403
Debugging with Xcode – 407
Continuous Integration with Xcode 5 – 412
以上包含了很多详细的说明和最好的方法来使用Xcode。不仅是简单的关于快捷键,包含了Xcode的工作方法和自定义Xcode 视图。
这里列出的快捷键是我发现最有用的。如果你有其他的留言,我会寻找方法改善它。