iOS Xcode自定義代碼塊以及遷移

文中將要介紹以下四點內(nèi)容

  • 代碼塊的意義
  • 自定義代碼塊入口
  • 代碼塊遷移
  • 代碼塊的編寫

一 . 意義在于節(jié)約時間成本

like
我在編譯器鍵入 strong, 回車
自動生成
@property (nonatomic, strong) <#Class#> *<#object#>;

二 . 如何自定義代碼塊

  1. 如下圖所示 選中一行代碼右鍵 crate code snippet
  2. 右上角方框快速進入
圖1
  1. 下圖填入描述, 以及快捷方式
圖2

三 . iOS Xcode自定義代碼塊遷移

  1. Command + Shift + G. 前往如下路徑的文件夾
  2. 路徑 : ~/Library/Developer/Xcode/UserData/CodeSnippets
  3. 把文件夾內(nèi)部的文件復制, 粘貼到另一臺電腦的Xcode同樣的文件夾中即可
  4. 重啟xcode

四 . 代碼塊編寫

下面我舉個栗子 . 0.O

- (UITableView *)<#tableview#> {
    
    if(!<#tableview#>) {
    
    <#tableview#> = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    <#tableview#>.delegate =self;
    <#tableview#>.dataSource =self;
    [<#tableview#> registerClass:[<#cell#> class] forCellReuseIdentifier:@"cellIdentifier"];
}
    return <#tableview#>;
}

#pragma mark - tableView delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return <#expression#>
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return <#expression#>
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    <#UITableViewCell#> *cell = [tableView dequeueReusableCellWithIdentifier:@"cellIdentifier"];
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}

注: <#class#> 即為可以替換的詞語.

我再舉個栗子

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

總結(jié)

  1. 留作備忘
  2. 給需要的人

完~
編者 : 夏天然后

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容