zoukankan      html  css  js  c++  java
  • OC基础之方法和参数的命名规范

    以前学过C/C++/Java/C#语言的童鞋可能刚开始对于OC的方法和参数的命名规范大为不爽

    举例来说,如下一个OC方法:

    - (void)tableView:(UITableView *)tableView
    commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
    forRowAtIndexPath:(NSIndexPath *)indexPath

    这个方法,如果在传统的C++编程语言中
    应该是:

    void tableViewCommitEditingStyleForRowAtIndexPath(
        UITableView *tableView,
        UITableViewCellEditingStyle editingStyle,
        NSIndexPath *indexPath);

    OC为了让你能更清楚地知道每个参数是派什么用处, 其实是把方法名给拆分了

    所以,好的命名规范的建议是:

    每个参数名换行,并且让每个参数后面的冒号尽量对齐(如果不麻烦的话:-))

    好的命名规范:

    -  (void)tableView:(UITableView *)tableView
    commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
     forRowAtIndexPath:(NSIndexPath *)indexPath
  • 相关阅读:
    在线心理测试脚本
    素数
    设置层叠效果
    年轻,无权享受...
    Unity3D之预设
    Json解析类
    php 正则表达式
    php 字符串处理
    php 基础语法
    SQL 函数
  • 原文地址:https://www.cnblogs.com/davidgu/p/3912032.html
Copyright © 2011-2022 走看看