Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you set code regions in Xcode?

Tags:

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.

like image 494
Ferdeen Avatar asked Feb 22 '09 13:02

Ferdeen


People also ask

How do I collapse code in Xcode?

Keep (hold) ⌘ (command) button in pressed condition and click on highlighted area. It will enable quick menu popover window with Fold option. Select Fold from menu list. It will fold your code and shows 3 dots, folding/covering entire block.

How do I hide lines in Xcode?

If you just want hide the blue lines (assuming that in future you may want to actually resume using Git) in the main menu under Xcode/Preferences (or Command + , ), choose the Source Control tab and uncheck Source Control: Enable Source Control . The other options will become greyed out.


2 Answers

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.

like image 56
mouviciel Avatar answered Oct 19 '22 03:10

mouviciel


You can also use:

// MARK: - 

or

// MARK: Initialization 

which is more portable than #pragma mark.

like image 22
0xced Avatar answered Oct 19 '22 04:10

0xced