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

你的呢?


当前回答

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

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.

其他回答

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

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

如果高亮显示搞砸了,如果你的变量没有高亮显示或其他任何东西,只需执行⌘-A⌘-X⌘-V,这将全部选中,剪切和粘贴,所有高亮显示将被纠正。所以只要按住⌘,然后按A X V。

无需重新编译的调试日志记录

cdespinosa的回答堆栈溢出问题我如何调试与NSLog(@“内部的iPhone模拟器”)?给出了一种不需要重新编译源代码的调试通过日志技术的方法。这是一个神奇的技巧,可以让代码摆脱调试的麻烦,有一个快速的周转,如果我早一点知道它,就可以为我省去无数的麻烦。

TODO comments

在注释前面加上TODO:将导致它显示在函数“快捷”下拉菜单中,例如:

int* p(0); // TODO: initialize me!

通过命令行控制Xcode的文本编辑器:xed

> xed -x                # open a new untitled document
> xed -xc foo.txt       # create foo.txt and open it
> xed -l 2000 foo.txt   # open foo.txt and go to line 2000

# set Xcode to be your EDITOR for command line tools
# e.g. for subversion commit
> echo 'export EDITOR="xed -wcx"' >> ~/.profile

> man xed               # there's a man page, too

在打开的文件之间来回导航: ⌥⌘← ⌥⌘→