**
如何自定义代码块
**
1 .选中一行代码右键 crate code snippet
2.右上角方框快速进入
iOS Xcode自定义代码块迁移
Command + Shift + G. 前往如下路径的文件夹
路径 : ~/Library/Developer/Xcode/UserData/CodeSnippets
把文件夹内部的文件复制, 粘贴到另一台电脑的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#> 即为可以替换的词语.
我再举个栗子
1
@property (nonatomic, assign) <#Class#> <#object#>;