讓您的Xcode鍵字如飛

手指在鍵盤上飛速跳躍,終端上的代碼也隨着飛舞,是的這確實很酷。優秀的程序員總是這麼一羣人,他們不拘於現狀,不固步自封,他們喜歡新奇的事,他們把自己發揮到極致。

指法攻略

放下您鍾愛的鼠標吧,在前行之中它終會成爲你的負累!

簡記:
command 用來導航,控制導航區域
alt 控制右邊的一些東西,比如Assistant Editor,utility editor
Control 編輯區域上的Jump bar的一些交互

Command 1~ 8: 跳轉到導航區的不同位置



Command 0 :顯示/隱藏導航區



Command Alt 1~ 6:在不同檢測器之間跳轉


Control Command Alt 1~4: 在不同庫之間跳轉



Control 1~ 6: 在Jump bar的不同標籤頁的跳轉。


Command Alt 0: 顯示/關閉工具區.
Command + Enter: 顯示標準單窗口編輯器
Command Alt Enter:打開Assistant editor
Command Alt Shift Enter: 打開版本控制編輯器
Command + Shift + Y:顯示/隱藏調試區
Command + Shift + J,可展示當前你在工程導航器中打開的文件
Cmd + . 方便地暫停運行iOS模擬器

查找
使用 Command + Shift + Option + F 來打開 Find navigator 的替換模式,如果你嫌麻煩,也可以使用 Command + Shift + F 來打開 Find navigator 的查找模式,如果你還嫌麻煩,使用 command + 3 來打開 Find navigator,然後開啓查找或者替換模式,選擇一種最適合自己的方式就好。


Snip20160702_6.png

快速打開
Command + Shift + O可以直接跳轉到某個方法定義或者指定的代碼文件。喜歡使用鍵盤但不喜歡使用鼠標的人會大愛這個快捷方式。鍵入第一個字母即可快速切換至某個文件或者找到特定的代碼行。比如鍵入vDL,最先展示的結果是帶有viewDidLoad()名的函數。


Command + Shift + O

幫助
Command + Shift + 0 (Zero)打開文檔和參考,鍵入代碼中的某個關鍵字,文檔提供了一些額外的資源和示例工程。當然也可以在變量、類或者方法名上執行Option+雙擊名稱操作,從而更方便地跳轉至文檔。

在類或者方法名上執行Option + Left點擊操作使用內聯幫助可幫開發者快速學習類或代碼片段的用法。如果點擊了彈出視圖底部的參考鏈接,那麼就可以方便地跳轉到Xcode提供的文檔中。


個人比較中意Option+雙擊名稱操作,畢竟來的直接。

代碼片段

Xcode的代碼片段(Code Snippets)創建自定義的代碼片段,當你重用這些代碼片段時,會給你帶來很大的方便。

常用代碼塊

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,並打開它;然後點擊File->New,並選擇服務(service)一項;在Actions篩選欄,輸入shell,然後雙擊運行shell腳本;在新添加的服務的菜單欄上,檢查Output replaces selected text;將腳本內容切換至sort | uniq;同時按下command + s,將服務保存爲 Sort & Uniq。

詳情可以參考之前的文檔:《mac 上自定義腳本命令》


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章