APP开发的干货 - 1、使用OC的代码规范

代码规范网址:http://www.csdn.net/article/2015-06-01/2824818-objective-c-style-guide
                         https://github.com/VincentSit/NYTimes-Objective-C-Style-Guide-ZH

1、方法的行数不能大于150,controller的文件代码行数不能大于800

2、#pragma mark 注释

控制器的注释

#pragma mark - --- lift cycle 生命周期 ---

#pragma mark - --- delegate 视图委托 ---

#pragma mark - --- event response 事件相应 ---

#pragma mark - --- private methods 私有方法 ---

#pragma mark - --- getters and setters 属性 ---

视图的注释

#pragma mark - --- init 视图初始化 ---

#pragma mark - --- delegate 视图委托 ---

#pragma mark - --- event response 事件相应 ---

#pragma mark - --- private methods 私有方法 ---

#pragma mark - --- setters 属性 ---

#pragma mark - --- getters 属性 —

3、属性注释的代码段

@property(nullable, nonatomic, readonly)<#Class#> *<#obj#> ; // <##>

@property(nullable, nonatomic, readwrite)<#Class#> *<#obj#> ; // <##>

@property(nullable, nonatomic, strong)<#Class#> *<#obj#> ; // <##>

@property(nullable, nonatomic, copy)<#Class#> *<#obj#> ; // <##>

@property(nullable, nonatomic, weak)<#Class#> *<#obj#> ; // <##>

@property(readonly, getter=is<#obj#>)BOOL <#obj#> ; // <##>

@property(null_resettable, nonatomic, strong)<#Class#> *<#obj#> ; // <##>

@property(nonatomic)<#Class#> <#obj#> ; // <##>

@property(nonatomic, assign)<#Class#> <#obj#> ; // <##>

NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_END

4、泛型中的协变和逆变

https://msdn.microsoft.com/zh-cn/library/dd799517.aspx

5、Objective-C 三大新特性

http://www.cocoachina.com/ios/20150617/12148.html

posted @ 2016-01-21 10:13  小沈曰  阅读(487)  评论(0编辑  收藏  举报