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

你的呢?


当前回答

“Ctrl+左/右箭头”进行字内文本导航。我使用这个特性将光标从变量中的一个“驼峰”跳转到下一个。

其他回答

Xcode支持文本宏,可以通过编辑菜单末尾的插入文本宏菜单调用。它们也可以使用Code Sense (Xcode的代码补全技术)来调用。

例如,键入键序列pi m control-period将插入#import "file"到你的代码中,file作为一个可编辑的标记,就像代码完成一样。

我已经为NSObject, UIView和UIViewController创建了自己的文件模板,所以当我创建新类时,这些文件都设置了私有部分,并在init和dealloc中记录类的地址。

示例(命名为'test'的NSObject派生类将像这样开始):

//=====================================================
// Private Interface
//=====================================================

@interface test (private)
@end

//=====================================================
// Public Implementation
//=====================================================

@implementation test

- (void)dealloc {
    NSLog(@">>> Dealloc: test [0x%X]", self);
    [super dealloc];
    NSLog(@"<<< Dealloc: test");
}

- (id) init
{
    self = [super init];
    if(self) {
        NSLog(@">>> Alloc: test [0x%X]", self);
    }
    return self;
}

@end

//=====================================================
// Private Implementation
//=====================================================

@implementation test (private)
@end

这方面有很多可用的资源,例如Cocoa dev:设计自己的Xcode项目模板。

使用xcodebuild命令行在共享构建机器上进行干净的构建:

cd project_directory
xcodebuild -configuration Release -alltargets clean
xcodebuild -configuration Release -alltargets

Control+R将所选文本作为shell脚本执行,该脚本将在选择后返回粘贴的输出!

切换到头文件/源文件

选项命令⌘向上箭头↑ 查看>切换到头文件/源文件

在。m和。h文件之间切换。

在Xcode 4中,这是ctrl⌘向上箭头↑