iOS Xcode自定义代码块以及迁移

1404次阅读  |  发布于3年以前

文中将要介绍以下四点内容

一 . 意义在于节约时间成本

like
我在编译器键入 strong, 回车
自动生成
@property (nonatomic, strong) <#Class#> *<#object#>;

二 . 如何自定义代码块

  1. 如下图所示 选中一行代码右键 crate code snippet
  2. 右上角方框快速进入

  1. 下图填入描述, 以及快捷方式

三 . iOS Xcode自定义代码块迁移

  1. Command + Shift + G. 前往如下路径的文件夹
  2. 路径 : ~/Library/Developer/Xcode/UserData/CodeSnippets
  3. 把文件夹内部的文件复制, 粘贴到另一台电脑的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#>;

总结

  1. 留作备忘
  2. 给需要的人

完~ 编者 : 夏天然后

作者:夏天然后 链接:https://www.jianshu.com/p/a901cd3f8139

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8