When we write many methods in a class of Xcode, it is often difficult to distinguish between the methods of some functions, and sometimes it is difficult to find some similar functions. This is the time to use Mark notation, a tagging tool that can quickly find the same kind of method.
The format is:
#pragma mark-... Here, write what you want to mark;
The sample code is as follows:
#import "SecondViewController.h"
@interface secondviewcontroller ()
@end
@implementation Secondviewcontroller
#pragma mark-Start loading page
-(void) viewdidload {
[super viewdidload];
Do no additional setup after loading the view.
}
#pragma mark-Initialization method
-(void) method1{
}
#pragma mark-the method that responds to user action
-(void) method2{
}
-( void) method3{
}-(void)
method4{
}
-(void) method5{
}
#pragma mark-Network request implementation
-( void) method6{
}
-(void) method7{
}
@end
As the code shows, it's handy to have a mark mark in front of some methods that are functionally similar, and then find some way through the navigation bar:
。
This makes it easy for others to read the code. We can also remove the "-" small horizontal line behind mark so that there is no split.
GitHub home: https://github.com/chenyufeng1991. You are welcome to visit.