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

你的呢?


当前回答

使用^T来交换前面两个字母

这适用于所有Cocoa应用程序,但我尤其喜欢在编码时使用它。使用^T (Control-T)来交换插入符号旁边的两个字母,或者当插入符号在末尾时,交换插入符号前面的两个字母。例如:

fi^T

... 就变成:

if

... 这是我经常犯的错别字。

其他回答

事实上,我可以使用Emacs作为我的编辑器,Xcode作为我的构建器/调试器……在我看来,这是两全其美。

你可以让Xcode在Info上运行预处理器。plist文件:

        <key>CFBundleShortVersionString</key>
    #ifdef DEBUG
        <string>1.0 (debug)</string>
    #else
        <string>1.0</string>
    #endif

详情见http://developer.apple.com/technotes/tn2007/tn2175.html。

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

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.

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

获取Colin Wheeler的完整Xcode键盘快捷键列表(PDF或PNG格式)。把它打印出来,放在显眼的地方(我把它贴在屏幕旁边的墙上)。

编辑: Xcode 3.2的更新版本

编辑2: Xcode 4的更新版本