When writing c#, in Visual Studio, you can set regions to group code accordingly. Being new to Xcode I can\'t seem to find a similar feature.
Using Xcode editor, you can collapse or expand any block of code by clicking in the little left margin. Moreover, you can put a mark in any point in the code with:
#pragma mark
your title as long as you want
Your mark will then appear in the middle popup menu on top of the editor window.
Update: I have found that a duplicate of this question exists here. The answers may be of interest.
Sorry for being pedantic but it's "Xcode", not "X-Code".
You can for example go:
#pragma mark -
or
#pragma mark Initialization
This will give you this kind of thing:
Without support for .Net style regions, being able to collapse all your functions is the next best thing.
command-option-shift-left arrow to collapse.
command-option-shift-right arrow to expand.
Xcode will remember the last state of collapsed functions.
one more option
#pragma mark - Initialization
If you want to have a folding zone with a custom section of your code then put your desired code inside braces {
}
, and it will become a folding zone.
But you have to keep in mind that braces also define variables scope, so this code should not have variables declarations which will be used outside these brackets.
You can also use:
// MARK: -
or
// MARK: Initialization
which is more portable than #pragma mark.