手指在鍵盤上飛速跳躍,終端上的代碼也隨著飛舞,是的這確實(shí)很酷。優(yōu)秀的程序員總是這么一群人扭勉,他們不拘于現(xiàn)狀鹊奖,不固步自封偏形,他們喜歡新奇的事液走,他們把自己發(fā)揮到極致。
指法攻略
放下您鐘愛的鼠標(biāo)吧柳弄,在前行之中它終會(huì)成為你的負(fù)累唱捣!
簡記:
command 用來導(dǎo)航,控制導(dǎo)航區(qū)域
alt 控制右邊的一些東西,比如Assistant Editor,utility editor
Control 編輯區(qū)域上的Jump bar的一些交互
Command 1~ 8: 跳轉(zhuǎn)到導(dǎo)航區(qū)的不同位置
Command 0 :顯示/隱藏導(dǎo)航區(qū)
Command Alt 1~ 6:在不同檢測器之間跳轉(zhuǎn)
Control Command Alt 1~4: 在不同庫之間跳轉(zhuǎn)
Control 1~ 6: 在Jump bar的不同標(biāo)簽頁的跳轉(zhuǎn)两蟀。
Command Alt 0: 顯示/關(guān)閉工具區(qū).
Command + Enter: 顯示標(biāo)準(zhǔn)單窗口編輯器
Command Alt Enter:打開Assistant editor
Command Alt Shift Enter: 打開版本控制編輯器
Command + Shift + Y:顯示/隱藏調(diào)試區(qū)
Command + Shift + J,可展示當(dāng)前你在工程導(dǎo)航器中打開的文件
Cmd + . 方便地暫停運(yùn)行iOS模擬器
查找
使用 Command + Shift + Option + F 來打開 Find navigator 的替換模式震缭,如果你嫌麻煩赂毯,也可以使用 Command + Shift + F 來打開 Find navigator 的查找模式,如果你還嫌麻煩拣宰,使用 command + 3 來打開 Find navigator党涕,然后開啟查找或者替換模式,選擇一種最適合自己的方式就好巡社。
快速打開
Command + Shift + O可以直接跳轉(zhuǎn)到某個(gè)方法定義或者指定的代碼文件膛堤。喜歡使用鍵盤但不喜歡使用鼠標(biāo)的人會(huì)大愛這個(gè)快捷方式。鍵入第一個(gè)字母即可快速切換至某個(gè)文件或者找到特定的代碼行晌该。比如鍵入vDL肥荔,最先展示的結(jié)果是帶有viewDidLoad()名的函數(shù)绿渣。
幫助
Command + Shift + 0 (Zero)打開文檔和參考,鍵入代碼中的某個(gè)關(guān)鍵字次企,文檔提供了一些額外的資源和示例工程怯晕。當(dāng)然也可以在變量、類或者方法名上執(zhí)行Option+雙擊名稱操作缸棵,從而更方便地跳轉(zhuǎn)至文檔舟茶。
在類或者方法名上執(zhí)行Option + Left點(diǎn)擊操作使用內(nèi)聯(lián)幫助可幫開發(fā)者快速學(xué)習(xí)類或代碼片段的用法。如果點(diǎn)擊了彈出視圖底部的參考鏈接堵第,那么就可以方便地跳轉(zhuǎn)到Xcode提供的文檔中吧凉。
個(gè)人比較中意Option+雙擊名稱操作,畢竟來的直接踏志。
代碼片段
Xcode的代碼片段(Code Snippets)創(chuàng)建自定義的代碼片段阀捅,當(dāng)你重用這些代碼片段時(shí),會(huì)給你帶來很大的方便针余。
常用代碼塊
1.copy:
@property (nonatomic,copy) NSString *<#string#>;
2.strong:
@property (nonatomic,strong) <#Class#> *<#object#>;
3.weak:
@property (nonatomic,weak) <#Class#> *<#object#>;
4.assign:
@property (nonatomic,assign) <#Class#> <#property#>;
5.delegate:
@property (nonatomic,weak) id<<#protocol#>> <#delegate#>;
6.block:
@property (nonatomic,copy) <#Block#> <#block#>;
7.mark:
#pragma mark <#mark#>
8.gmark:
#pragma mark - <#gmark#>
9.warning:
#warning <#message#>
10.ReUseCell:
static NSString *rid=<#rid#>;
<#Class#> *cell=[tableView dequeueReusableCellWithIdentifier:rid];
if(cell==nil){
cell=[[<#Class#> alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:rid];
}
return cell;
11.initObj:
if(self=[super init]){
<#init#>
}
return self;
12.dataFill:
-(void)dataFill:(<#ModelClass#> *)<#model#>{
<#code#>
}
13.MainGCD:
dispatch_async(dispatch_get_main_queue(), ^{
<#code#>
});
14.GlobalGCD:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
<#code#>
});
15.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#>
});
16.OnceGCD:
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
<#code to be executed once#>
});
黑技能(給代碼排序)
使用Spotlight來搜索Automator饲鄙,并打開它;然后點(diǎn)擊File->New圆雁,并選擇服務(wù)(service)一項(xiàng)忍级;在Actions篩選欄,輸入shell伪朽,然后雙擊運(yùn)行shell腳本轴咱;在新添加的服務(wù)的菜單欄上,檢查Output replaces selected text;將腳本內(nèi)容切換至sort | uniq烈涮;同時(shí)按下command + s朴肺,將服務(wù)保存為 Sort & Uniq。
詳情可以參考之前的文檔:《mac 上自定義腳本命令》