一些写代码的常见规范

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一些写代码的常见规范相关的知识,希望对你有一定的参考价值。

1.用在.h 文件的@class 和.m文件的#import  替代  .h文件的#import

2.多用字面量 NSNumber *number [email protected];替代 NSNumber *number = [NSNumber numberWithInt:1];

3.多用类型常量,少用宏定义

   static nssthring const AnimalTime = 0.3;

   extern NSString *const EOCStringConstant [email protected]"value";

4.多用枚举表示状态,选项。

5.对象内部尽量用实例变量

以上是关于一些写代码的常见规范的主要内容,如果未能解决你的问题,请参考以下文章