- One of the best features in Xcode that developers forgot to use is #pragma mark directives
- Pragma mark is simply a way to organize your methods at method pop up list in Xcode & help us to better code implementation.
- It has no impact on your code only just to find the method easily and reference
Objective c:
#pragma mark
Example
# pragma mark example
- (void) pragmaMarkExample {
//function body
}
# pragma mark - example
- (void) pragmaMarkExample {
// function body
}
Swift:
//MARK:
// MARK: create only the title
func pragmaMark() {
//function body
}
//MARK:-
// MARK:- create only the title
func pragmaMark() {
//function body
}
Create only separator for methods
// MARK:
func pragmaMark() {
//
}
Xcode now supports //TODO: and //FIXME: landmarks to annotate your code and lists them in the jump bar.
//TODO: or //TODO: -
- When you need to set a reminder for code that you need to revisit TODO will be used.
- TODO can be used either inside or outside a method.
//FIXME: or //FIXME: -
- Fixme works in a similar manner, as it can be place either inside or outside a method.
- Fixme is used to refer a bug, later you can track and fix it easily.
// MARK: - Pragma Mark
func validation() {
//TODO: something here
//FIXME: Fix the error
}
// MARK: - Pragma Mark
func validation() {
//TODO: - something here
//FIXME: - Fix the error
}