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

你的呢?


当前回答

Xcode支持文本宏,可以通过编辑菜单末尾的插入文本宏菜单调用。它们也可以使用Code Sense (Xcode的代码补全技术)来调用。

例如,键入键序列pi m control-period将插入#import "file"到你的代码中,file作为一个可编辑的标记,就像代码完成一样。

其他回答

看看一个关于“在Xcode中变得高效”的视频:becoming-productive-in- Xcode

至于“快速打开”功能——它很棒,但我总是错过TextMate用于浏览项目和文件(符号,方法等)的cmd-shift-t。

这就是为什么我发布了一个Xcode插件来提供这个功能。它叫做Code Pilot,你可能想看看它:http://macoscope.net/en/mac/codepilot/

在Xcode的Groups and Files窗格中选择Group,然后Edit > Sort by > Name。

您可能希望在组的上下文菜单中找到它,但它不在那里。

Credit:在Xcode中排序文件。

在PyObjC中,你可以为符号下拉列表做类似的#pragma标记:

#马克:Foo

and

#马克:-

我刚从Windows世界来到Xcode(就像其他许多人一样),我遇到的第一个怪招就是尝试用TAB键“缩进选定的文本块”。

通常,当使用Windows编辑器时,您选择一个文本块,无论何时按TAB(或shift TAB)键,所选的文本都会右/左跳转。然后,一旦确定了文本的新位置,就停止按TAB键。

好吧,在Xcode中,这是完全不同的,因为当你按TAB键时,整块文本消失了,留给你一张愚蠢的脸,内心有些愤怒……

但后来,出于偶然或直觉或其他原因,有一天我发现了一些变通方法,可以达到你在正确的窗口编辑器下可能得到的相同效果。 步骤如下:

Select the text block as you might do under Windows. Instead of pressing TAB, leave your instincts away, and "copy the text block" (typically CTRL+C (yuck)). Then, without deselecting the text, (pressing SHIFT if needed), extend the beginning of the selection and place it on the position you would like your new text to appear. Paste the beforementioned text (typically CTRL+V (yuck again)). Result: The previous text block gets substituted by "the new" one (of course, itself), but the "auto indent" capabilities of Xcode (or someone else, who cares), will auto place the text starting onto the new position we chose in step 3. A big smile appears on your face.

这有点棘手,但当你习惯了,你会发现自己经常使用它。

享受! !