iOS常常用到的代码块

使用时直接把对应代码拖拽到右下角就好了async

图中从上到下的含义依次是:
①Title
代码片断的标题
②Summary
代码片断的描述文字
③Platform
能够使用代码片断的平台,有IOS/OS X/All三个选项
④Language
能够在哪些语言中使用该代码片断
⑤Completion Shortcut
代码片断的快捷方式,例:copy
⑥Completion Scopes
能够在哪些文件中使用当前代码片断,好比所有位置,头文件中等,固然能够添加多个支持的位置。
最后的一个大得空白区域是对代码片断的效果预览。
一切设置完成之后,点击该菜单右下角的Done按钮,新建工做就结束了。atom

 

1.strong:spa

@property (nonatomic,strong) <#Class#> *<#object#>;


2.weak:code

@property (nonatomic,weak) <#Class#> *<#object#>;


3.copy:orm

@property (nonatomic,copy) NSString *<#string#>;


4.assign:ip

@property (nonatomic,assign) <#Class#> <#property#>;


5.delegate:ci

@property (nonatomic,weak) id<<#protocol#>> <#delegate#>;


6.block:get

@property (nonatomic,copy) <#Block#> <#block#>;


7.mark:
 string

#pragma mark <#mark#>

8.ReUseCell:it

static NSString *rid=<#rid#>;  

 <#Class#> *cell=[tableView dequeueReusableCellWithIdentifier:rid];  

 if(cell==nil){  

 cell=[[<#Class#> alloc] initWithStyle:UITableViewCellStyleDefault      reuseIdentifier:rid];  

 }  

 return cell;

9.MainGCD:

dispatch_async(dispatch_get_main_queue(), ^{  
<#code#>  
  });

10.AfterGCD:

 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(<#delayInSeconds#> * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{  
<#code to be executed after a specified delay#>  
});

11.OnceGCD:

 static dispatch_once_t onceToken;  
 dispatch_once(&onceToken, ^{  
<#code to be executed once#>  
 });

代码片断备份:

Xcode中的代码片断默认放在下面的目录中:

~/Library/Developer/Xcode/UserData/CodeSnippets

咱们能够将目录中的代码片断备份,也能够将其直接拷出来放在不一样的电脑上使用。

相关文章
相关标签/搜索