您的位置:首页 > 其它

[Xcode]自己常用的Code Snippets、Xcode插件、文件目录

2016-04-19 16:37 513 查看

目录

目录

Code Snippets Xcode代码块

常用的Xcode插件

Xcode相关的文件目录

Code Snippets Xcode代码块

Code Snippets Library是Xcode中比较方便的管理代码块的功能,可以方便的用快捷方式敲出保存起来的代码,这里保存一下自己常用的Code Snippets,方便换机器或更新Xcode时取用。

属性Snippets

@property (strong, nonatomic) <#type#> *<#name#>;
@property (weak, nonatomic) <#type#> *<#name#>;
@property (assign, nonatomic) <#type#> <#name#>;
@property (copy, nonatomic) <#type#> *<#name#>;
@property (weak, nonatomic) id<<#delegate#>> delegate;


关闭自动调整ScrollView的insets

if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) {
self.automaticallyAdjustsScrollViewInsets = NO;
}


配置cell

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier = @"<#identifier#>";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];

if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}

cell.textLabel.text = @"<#cell标题#>";

return cell;
}


cel构造方法

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {

}
return self;
}


cell自定义工厂方法

+ (instancetype)cellWithTableView:(UITableView *)tableView {
static NSString * identifier = @"<#identifier#>";
<#customCell#> *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
cell = [[<#customCell#> alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
//设置选中时的效果为None;
cell.selectionStyle=UITableViewCellSelectionStyleNone;
}
return cell;
}


回到主线程

dispatch_async(dispatch_get_main_queue(), ^{

});


新开一个异步线程

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

});


配置请求参数

NSMutableDictionary *params = [NSMutableDictionary dictionary];
params[@"<#parameter#>"] = @"<#value#>";
params[@"<#parameter#>"] = @"<#value#>";
params[@"<#parameter#>"] = @"<#value#>";
params[@"<#parameter#>"] = @"<#value#>";


NSLog宏

NSLog(FORMAT, ...) NSLog((@"%s[Line:%d]" FORMAT), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);


常用的Xcode插件

自己常用的插件整理:安装
Alcatraz
管理其他插件,在升级Xcode导致插件失效的时候能非常高效的重新安装整个插件列表

Alcatraz Package Manager - 管理插件的插件

命令行安装:

创建
Xcode
插件目录(不存在就创建)

mkdir -p ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins


github
下载Alcatraz

curl -fsSL https://raw.github.com/supermarin/Alcatraz/master/Scripts/install.sh | sh


VVDocumenter-Xcode - 文档注释插件

KSImageNamed-Xcode - imageNamed:图片拾取插件

OMColorSense - 直观颜色查看和调用调色盘取色插件

Peckham - 头文件导入插件Ctrl+Command+P

SCXcodeSwitchExpander - Switch自动展开枚举分支插件

XAlign - 代码对齐插件

HOStringSense - NSString字符串统计,输入自动转义插件

Xcode相关的文件目录

目录、UUID:主要是因为之前插件因为升级Xcode失效,需要读取Xcode的UUID导入到插件中

描述文件目录:方便删除Xcode安装的无效描述文件

读取Xcode的UUID

defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID


打开Xcode插件目录

open ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/


Xcode描述文件目录

open ~/Library/MobileDevice/Provisioning\ Profiles
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: