Sometimes we need to search the code for special symbols or snippets of code, and it's not very efficient to navigate code snippets based on symbols or using the search function. In order to use normal English to identify important code snippets, you can insert Special-format annotations into your code. These annotations do not add any special functionality to the application, but rather create logical sections in the code. When you click the last part of the path above the code Editor, these sections are displayed along with other code symbols. There are three types of comment tags:
// MARK:-<label name> // TODO: <text want to remember> // fixme: <text you want to remember>
The Mark comment tag is used to insert a horizontal line in the symbol drop-down list, which can be used to group different methods depending on the function or the responsible programmer. Usually written before the implementation code of a method, for example:
// MARK:-Do initialization before view appear-(void) viewdidload { [super viewdidload]; additional setup after loading the view from its nib.}
Corresponding, click the last line of the address bar, will pop up the drop-down list as follows:
Note: Using the mark annotation has the same effect as using #pragma mark, which is equivalent to:
#pragma mark-do initialization before view appear-(void) viewdidload { [super Viewdidload] ; // Do any additional setup after loading the view from its nib.}
Tagging TODO and fixme also inserts a string in the symbol drop-down list, which, as the name implies, reminds you of the task you need to fix or complete. These two symbols are unobstructed to mark the work to be done, either before the method name or inside the method:
// Mark:do initialization before view appear // Todo:writeHere is OK-(void) viewdidload { [super Viewdidload]; // Do any additional setup after loading the view from its nib. // Todo:you has do nothing here // fixme:please do some thing}
The corresponding symbol drop-down list is displayed as follows:
Note: It is certainly not that the mark mark cannot be written inside the method, and in fact any place where you can write a comment can use these three tags. However, in order to make it easier to distinguish between these 3 tags, it is best to follow a common rule that everyone is complying with when writing code.
Add special tags to your code in Xcode