zoukankan      html  css  js  c++  java
  • iOS代码段整理

    实际开发项目中为了提高开发效率,可以在xcode中设置代码段,这样输入一个属性是只要输入快捷键 按tab就可以输出模板。

    <##> 作用是占位,## 之间可以输入提示文字。如<#type#> *<#value#>;

    如,@property (nonatomic, strong) <#NSString#> *<#name#>;

    写完这样的代码后,选中稍等下,然后拖动会有个箭头,拖动代码段出。

    列举一些常用的:

    1.@property (nonatomic, strong) <#type#> *<#name#>;    shorcut: strong

    2.@property (nonatomic, assgin) NSInteger  <#name#>;         assgin

    3.#pragma mark - <#mark#>                           mark

    4.可以加注释

    /** <#注释#> */

    @property (nonatomic, strong) <#type#>  *<#name#>;        

     5.懒加载

    - (<#class#> *)<#name#> {

       if (_<#name#> == nil) {

        _<#name#> = [[<#class#> alloc] init];

      } return _<#name#>;

    }

    6.

    #pragma mark - UITableView
    #pragma mark UITableViewDelegate
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return <#number#>;
    }

    - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return <#number#>;
    }

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return <#number#>;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return <#number#>;
    }
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSInteger row = indexPath.row;
    NSInteger section = indexPath.section;
    return <#number#>;
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@""];
    NSInteger section = indexPath.section;
    NSInteger row = indexPath.row;
    return cell;
    }

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    }

  • 相关阅读:
    Prometheus监控神器-服务发现篇(二)
    Prometheus监控神器-服务发现篇(一)
    Prometheus监控神器-Alertmanager篇(4)
    Prometheus监控神器-Alertmanager篇(3)
    Prometheus监控神器-Rules篇
    Linux内核分析——字符集总结与分析
    Linux内核分析——ELF文件格式分析
    Linux内核分析——程序破解
    Linux内核学习总结
    《Linux内核设计与实现》课本第四章学习总结
  • 原文地址:https://www.cnblogs.com/menchao/p/9684672.html
Copyright © 2011-2022 走看看