博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IOS 命名规范
阅读量:2393 次
发布时间:2019-05-10

本文共 685 字,大约阅读时间需要 2 分钟。

小驼峰命名法(CamelCase):第一个单词小写字母开头,其他单词首字母大写;
大驼峰命名法(PascalCase):   所有首字母大写。
命名规范:
1、类名、协议名:遵循大驼峰命名法
2、常量:这里的常量指的是宏(#define)、枚举(enum)、常量(const)等,使用小写”k“作为前缀,名称遵循大驼峰命名法
3、方法
* 方法名和方法参数遵循相同的规则,使用小写开头的小驼峰法;
* 方法名和参数尽量读起来像是一句话;
* 方法名不允许使用“get“前缀;
* -或+与返回类型间留一个空格,但参数列表之间不要留间隔;
* 如果参数过多,推荐每个参数各占一行;
 例如:- (void)doSomethingWithString:(NSString *)theString(NSInteger *)theInteger {   ...   }  ;
4、变量:
类成员变量,属性,局部变量,使用小写开头的小驼峰法,其中类成员变量在名称最后加一个下划线,比如:myLovalVariable, myInstanceVariable_ ;变量名的名称尽量可以推测其用途,具有描述性
书写规范:
1. 在m文件中对当前类属性进行引用的时候,使用self.property的方式,用以区分局部变量;对属性进行赋值的时候使用“点”赋值,即A.property = value;
2. 使用import引用头文件的工作全部放到 .h 文件中进行,m文件只保持对当前类头文件的引用
3. 如果m文件中有较多的method,使用 #pragma mark 标记对方法进行分组,便于查看

转载地址:http://fsgab.baihongyu.com/

你可能感兴趣的文章
3D Math Primer for Game Programmers (Coordinate Systems)
查看>>
3D Math Primer for Game Programmers (Matrices)
查看>>
3D Math Primer for Game Programmers (Vector Operations)
查看>>
3D Math Primer for Game Programmers (View Matrix)
查看>>
IDL Save a Procedure that Restores Variable Data
查看>>
IDL find if a file or directory exist
查看>>
Sun Grid Engine state meaning
查看>>
IDL conver string to int
查看>>
IDL command line arguments
查看>>
Change the xterm background color for ICEWM
查看>>
IDL plot legend
查看>>
Some notes about the time
查看>>
latex 图片的使用
查看>>
IDL save postcript file
查看>>
IDl save the command line to file
查看>>
3D Math Primer for Game Programmers (quaternion)
查看>>
IDL 全局变量
查看>>
plot without data IDL
查看>>
Distance Transform
查看>>
IDL plot with white background
查看>>