注釋規(guī)范
創(chuàng)建文件
文件前綴:DD代表xx的文件
文件命名:DD+功能描述+類(lèi)型,例如歷史訂單列表控制器:DDHistoryOrderListController
注釋
類(lèi)的注釋
創(chuàng)建完類(lèi)之后,需要在如下部分寫(xiě)清楚文件作用:
//
// ViewController.h
// test
//
// Created by dry on 2017/9/18.
// Copyright ? 2017年 dry. All rights reserved.
//
// 類(lèi)功能描述
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
屬性注釋
屬性
//
// DDUser.h
// test
//
// Created by dry on 2017/9/18.
// Copyright ? 2017年 dry. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface DDUser : NSObject
// 姓名
@property (nonatomic, strong) NSString *name;
// 年齡
@property (nonatomic) NSUInteger age;
@end
變量
@interface ViewController ()
{
NSString *_city;//城市
NSString *_cityCode;//城市編碼
}
@end
方法注釋
頭文件中
1、不攜帶參數(shù)的方法直接用///+描述
2、攜帶參數(shù)的方法統(tǒng)一用cmd+option
/// Description
- (void)startRunning;
/**
<#Description#>
@param date <#date description#>
*/
- (void)startRunningWithDate:(NSDate *)date;
順序:類(lèi)引用,宏定義,枚舉,代理,屬性,方法
源文件中
源文件中
方法注釋用//或cmd+option,視情況定
方法需要分類(lèi),一類(lèi)定義一個(gè)mark,比如:
#pragma mark - Timer
關(guān)于timer的方法都在這
#pragma mark - delegate
代理方法都在這
注意:改對(duì)方寫(xiě)的方法時(shí),方法注釋里寫(xiě)上自己名字英文簡(jiǎn)寫(xiě),比如:MX,BJB,LX,WWP。每次修改更新最新的名字簡(jiǎn)寫(xiě)。在自己創(chuàng)建的類(lèi)中不用寫(xiě)自己名字,但是如果有別人修改過(guò),你再改得時(shí)候需要更新名字簡(jiǎn)寫(xiě)。