文中將要介紹以下四點內(nèi)容
- 代碼塊的意義
- 自定義代碼塊入口
- 代碼塊遷移
- 代碼塊的編寫
一 . 意義在于節(jié)約時間成本
like
我在編譯器鍵入 strong, 回車
自動生成
@property (nonatomic, strong) <#Class#> *<#object#>;
二 . 如何自定義代碼塊
- 如下圖所示 選中一行代碼右鍵 crate code snippet
- 右上角方框快速進入

圖1
- 下圖填入描述, 以及快捷方式

圖2
三 . iOS Xcode自定義代碼塊遷移
Command+Shift+G. 前往如下路徑的文件夾- 路徑 :
~/Library/Developer/Xcode/UserData/CodeSnippets- 把文件夾內(nèi)部的文件復制, 粘貼到另一臺電腦的Xcode同樣的文件夾中即可
- 重啟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é)
- 留作備忘
- 給需要的人
完~
編者 : 夏天然后