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

你的呢?


当前回答

通过命令行控制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

其他回答

按下“⌘D”激活“Open this quick”,它会使用所选文本导航到“Open quick”的第一个结果。如果所选文本的格式为<filename:lineNumber>,(包含或不包含<>)“快速打开此文件”将带您到文件加行号。

你可以结合下面的建议:

你可以使用这个宏写包含日志条目的文件名和行号的日志:(确保在你的目标调试配置中使用的C标志上定义-DDEBUG=1)

#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s <%@:%d> " fmt), __PRETTY_FUNCTION__, [[NSString stringWithFormat:@"%s", __FILE__ ] lastPathComponent] ,__LINE__, ##__VA_ARGS__)
#else
#define DLog(format, ...)
#endif

在DLog()输出中,双击“<”字符选择<filename:lineNumber>,然后按下“⇧⌘D”将打开源代码中日志所在的行。

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

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.

当在多个键盘上使用Code Sense时,使用control +来显示可用的补全列表,control +。插入最有可能的补全符,并control + / & shift + control + /在占位符令牌之间移动。所有的键都在键盘的主行下面,这对肌肉记忆有好处。

右键单击函数中的变量,然后单击edit all in scope。自从我发现了这个,我就一直在用它。

ctrl⌘T

用alt-向前或向后移动一个完整的单词。使用cmd-alt-向前或向后移动历史记录中的文件。使用cmd-alt-在接口和实现之间切换。

用cmd-=跳转到构建错误列表中的下一个错误。使用cmd-shift-f显示多个Find面板。使用cmd-shift-e切换完整的编辑器可见性。

使用cmd-0跳转到项目选项卡,使用cmd-shift-b跳转到构建选项卡,使用cmd-shift-y跳转到调试选项卡(与操作的关键命令相同,添加了shift)。