Code annotations are often overlooked so that they are more difficult to maintain later. We are prepared to develop a set of normative annotation systems before the start of the XX project, and we are committed to achieving the results even if the maintenance staff changes quickly.
1. Attribute Comments
The attribute comment uses the/** comment */Document comment format. The advantage of this comment compared to//annotation is that this property can display a Chinese comment below the smart hint at a later reference
If you are not in the Dong Platinum Blog Park See this article please click to view the original text.
For example:
/** Recovery Rate */@property (Nonatomic,strong) Mtpoicomparem *replyrate;/** reply speed */@property (nonatomic,strong) Mtpoicomparem * Replyspeed;
You can see the following effect on subsequent calls
And then, when you maintain the finished code, you can quickly see the explanation of this property on the right side of the quickhelp when you point the cursor to that property.
From the actual development point of view, not all attributes need to be annotated, as long as the attribute name can be translated from English literal or simple obvious attributes do not need to add attribute comments
@property (nonatomic,copy) nsstring *name; @property (nonatomic,assign) float Avgscore; @property (nonatomic,assign) int Dealid; @property (nonatomic,assign) float price; @property (nonatomic,assign) int feedbacknum;
① properties that cannot be quickly and distinctly understood by property names must be commented on, such as whose index is it? However, attributes that have the following attributes must be annotated
② a state-like tag may have 0,1,2 three cases to write comments with several scenarios
The literal translation of the ③ attribute name is not clear.
The above features correspond to the following code:
/** Top Category Subscript */@property (nonatomic,assign) int index;/** Project Type 1 is group 2 is coupon */@property (nonatomic,assign) int type;/** The industry average data */@property (nonatomic,copy) NSString *catevalue;
Here are the steps to introduce a code block. the code block for unifying a property comment is /** < #注释 #>*/ shortcut key is XX
2. Steps to introduce a code block
1. Copy the orange section to any location in the project. The inside part is automatically shrunk into a block.
Then select these to drag into the lower-right corner of the code block.
Drag and drop will display the settings box, set as required
Then click Done and this code block will exist in Xcode.
The advantage of using a code block is that you can hit the shortcut key in the project and enter the code immediately to appear your own presets and, press the TAB key to quickly switch to a small block to write
3. Method Set Annotations
System has a self-brought method set comment code block
But this is not with the divider line, if you want to add a divider line also need to add mark-and then follow the comment, a little trouble
After use can achieve the following effect
Now unify, give the code block
#pragma mark-**************** <# Enter comment #> shortcut key for Mark
The reason for the intermediate use of * * * is to avoid overlapping with the following comments in front of difficult to watch
The method set of the data source method or Proxy method for all classes must be preceded by a line of method set annotations to be delimited. (code requires that several proxy methods for a class should be written together)
4. General notes
Somewhere in the project the logic may be more complex or the core idea of the code, this place should be annotated as a note, but also conducive to maintaining the code, so that others take over the code.
For example:
Now unify, give the code block
//------<# Single-line comment #> shortcut key is GG
5. Priority Notes
This key note can be customized, and I give the code block of the comments I highlighted, and we recommend that you be unified and easy to see
//$$$$$ shortcut key is DD
Generally written in a large project often need to jump past the modification of the place, the use of this line of code to quickly hit the DD enter into this
Sometimes when you need to find them, you just have to hit them in the project search to quickly locate them.
It is also possible to set priority $$ or $$$, where emphasis or common exceptions are recommended without being stingy.
If you are not in the Dong Platinum Blog Park See this article please click to view the original text. Reprint please indicate the source.
iOS side item annotation specification with unified code block