随着大量的Xcode新手的涌入,我相信会有很多Xcode的技巧和技巧可以分享。
你的呢?
随着大量的Xcode新手的涌入,我相信会有很多Xcode的技巧和技巧可以分享。
你的呢?
当前回答
User Scripts菜单中有很多好东西,而且添加自己的脚本也相对容易。例如,我添加了一个快捷方式并将其绑定到cmd-opt—在我的代码中插入注释分隔符和#pragma标记来快速分解文件。
# !/bin/sh Echo -n "//================....================ #pragma mark”
当我点击cmd-opt——时,这些行被插入到我的代码中,光标被预先定位为编辑pragma mark组件,该组件显示在符号弹出框中。
其他回答
当您在一个方法上使用代码完成,并且它有多个参数时,使用CTRL + /移动到下一个需要填充的参数。
Xcode代码格式化…当你想要编写代码时,它是你需要的东西之一吗 可读性和外观良好。
您可以自己格式化代码,也可以使用脚本节省时间。
一个好方法是…使用Uncrustify。在Xcode中的代码格式化中有解释。
我已经为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项目模板。
通过命令行控制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
触控板:
向上滑动三个手指-在头文件和源文件之间切换,这比Cmd + Opt + Up更容易; 向下滑动三个手指-在选择类或方法时切换声明和定义,目前发现这两种; 向左滑动三个手指-返回(Cmd + Opt + left); 向右滑动三个手指-前进(Cmd + Opt +右);
用Xcode 3.2.5测试。