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

你的呢?


当前回答

在shell构建阶段,您可以使用以下格式写入stderr:

<filename>:<linenumber>:错误|警告|备注:<消息>\n .

它与gcc用来显示错误的格式相同。filename:linenumber部分可以省略。根据模式(错误,警告,注意),Xcode将显示你的消息与红色或黄色徽章。

如果你包含一个绝对文件路径和行号(如果错误发生在一个文件中),双击构建日志中的错误让Xcode打开文件并跳转到行,即使它不是项目的一部分。非常方便。

其他回答

CTRL + Alt +⌘+ r清除日志

能够快速查看可以从超类中重写的所有方法。例如,当扩展UITableViewController时,我只需要输入我的实现:

- ta

然后我按ESC键,看到我的超类中所有以“ta”开头的方法,比如

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

这也适用于采用协议。

Xcode动作的键绑定

我也喜欢“重新缩进”。,则没有默认快捷方式,但您可以从“键绑定”首选项窗格的“文本键绑定”选项卡添加一个。

这本身就能节省时间。只需查找您最喜欢的操作和添加/编辑键盘快捷键!

我发现一个很方便的默认设置是CMD+"和CMD+'来添加/删除垂直分割。按住这些选项,现在你有相同的水平。但如果这些手势不适合你,你可以随时改变它们。

没有多少键盘快捷键,但是源代码中的TODO注释显示在编辑器顶部的方法/函数下拉列表中。

例如:

// TODO: Some task that needs to be done.

在方法和函数的下拉列表中显示,以便您可以直接跳转到它。

大多数Java ide在滚动条中为这些任务标记显示一个标记,这样更好,但这也可以工作。

Cmd+Option+O to open a file in a separate window. Can configure Tab to always indent. I frequently use it to indent an entire file. Ctrl+Arrow keys to move between camel case words. If you have OneTwo, you can move from One to Two with Ctrl+Right arrow. You can use emacs bindings, there's even kill ring! I use the Ctrl+w and Cmd+C together when I need to copy two different pieces of text. In the documentation browser, you can restrict your searches to a particular library, e.g., just iOS 4.2 library. This helps me focus on API available only on a particular iOS/Mac version of the SDK. Cmd+Shift+A to build and analyze.