随着大量的Xcode新手的涌入,我相信会有很多Xcode的技巧和技巧可以分享。
你的呢?
随着大量的Xcode新手的涌入,我相信会有很多Xcode的技巧和技巧可以分享。
你的呢?
当前回答
使用^T来交换前面两个字母
这适用于所有Cocoa应用程序,但我尤其喜欢在编码时使用它。使用^T (Control-T)来交换插入符号旁边的两个字母,或者当插入符号在末尾时,交换插入符号前面的两个字母。例如:
fi^T
... 就变成:
if
... 这是我经常犯的错别字。
其他回答
我刚从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.
这有点棘手,但当你习惯了,你会发现自己经常使用它。
享受! !
能够快速查看可以从超类中重写的所有方法。例如,当扩展UITableViewController时,我只需要输入我的实现:
- ta
然后我按ESC键,看到我的超类中所有以“ta”开头的方法,比如
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
这也适用于采用协议。
如果高亮显示搞砸了,如果你的变量没有高亮显示或其他任何东西,只需执行⌘-A⌘-X⌘-V,这将全部选中,剪切和粘贴,所有高亮显示将被纠正。所以只要按住⌘,然后按A X V。
重命名多个项目共享的文件:
打开所有项目。 重命名一个项目中的文件。 Xcode自动调整所有打开的项目,以反映文件的新名称。
你可以对Xcode处理代码格式的方式进行很多调整,但前提是你要通过命令行更改设置。我编写了一个小程序,可以让你根据自己的喜好调整它们。享受:)
Xcode格式化选项