随着大量的Xcode新手的涌入,我相信会有很多Xcode的技巧和技巧可以分享。

你的呢?


当前回答

快照,File>Make Snapshot,如果您没有使用适当的版本控制系统,提供了一种快速保存项目修订的方法。这是一种尝试巨大的、潜在的破坏性变化的好方法。

其他回答

使用类浏览器显示继承的方法

Apple's API reference documentation does not show methods inherited from a superclass. Sometimes, though. it's useful to be able to see the full range of functionality available for a class -- including a custom class of your own. You can use the Class Browser (from the Project menu) to display a flat or hierarchical list of all the classes related to a current project. The upper pane on the right hand side of the browser window shows a list of methods associated with the object selected in the browser. You can use the Configure Options sheet to select "Show Inherited Members" to show inherited methods as well as those defined by the selected class itself. You click the small book symbol to go to the corresponding documentation.

使用]自动插入[到正确的位置

我来自。net背景,所以我习惯于输入一个符号,然后输入它的一个方法名。所以我总是忘记在开始输入对象名称之前包含[。通常这意味着我需要转到行首并手动添加[。我没有意识到我只需在当前光标位置按下],它就会自动添加。

有几种方法可以使用它:要么在输入函数名之后,要么在输入函数名之前。

方法一:在函数名后面

myObject testMethod]

... 就变成:

[myObject testMethod]

…插入符号位于]之后。

方法二:在函数名前面

myObject]

... 就变成:

[myObject ]

... 插入符号位于]的正前方。

后者(2)的优点是代码补全将根据对象的方法进行筛选。而对于前者(1),如果你试图在myObject之后立即调用代码补全,它将不会被过滤。(2)的另一个优点是它的行为更像其他使用点表示法的编程语言。然后只需输入对象的名称[而不是]。访问一个方法。

一些技巧可以在Xcode Tools tips中找到。

⌘'来正确格式化(重新缩进)您的代码

编辑:显然重缩进功能(编辑>格式>重缩进)没有默认的快捷方式。我想我很久以前就分配了一个(在Preferences > Key bindings中),甚至不记得了。抱歉误导你了。

我不太喜欢xcode中内置的代码格式化/reindent功能,所以我发现使用uncrustify作为代码格式化器非常有用。它可以作为用户脚本使用:http://hackertoys.com/2008/09/18/adding-a-code-beautifier-script-to-xcode/