随着大量的Xcode新手的涌入,我相信会有很多Xcode的技巧和技巧可以分享。
你的呢?
随着大量的Xcode新手的涌入,我相信会有很多Xcode的技巧和技巧可以分享。
你的呢?
当前回答
按下“⌘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”将打开源代码中日志所在的行。
其他回答
我最喜欢的是这些常用的编辑器快捷方式:
⌘+ 0将您从调试模式返回到编辑器。 ⌘+ Shift + R带您从调试模式到编辑器视图(项目模式) ⌘+ Shift + E“最大化”编辑器(当你有构建结果等显示在编辑器上方时,这非常有用,你只是想让你的源编辑器更高) Ctrl + 2显示当前代码的大纲 ⌘+ Return运行应用程序 ⌘+ Shift + Return结束应用程序
我不太喜欢xcode中内置的代码格式化/reindent功能,所以我发现使用uncrustify作为代码格式化器非常有用。它可以作为用户脚本使用:http://hackertoys.com/2008/09/18/adding-a-code-beautifier-script-to-xcode/
Cmd + Ctrl + up / down折叠或展开所有函数。
我刚从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.
这有点棘手,但当你习惯了,你会发现自己经常使用它。
享受! !
alt -左&右转到行尾/开始。这与ctrl -左&右一起移动到下一个大写字母或换行字。这两个帮我省了不少时间