13

I use #pragma mark - Description frequently to organize my methods in Xcode. However, I find that sometimes I need to categories and subcategories for my methods, like this:

  • Public Methods

    • Helper Methods
      • aMethod
    • Other Type of Methods
      • anotherMethod
  • Private Methods

    • Some Type of Method
      • aPrivateMethod

Is this possible?

pasawaya
  • 11,515
  • 7
  • 53
  • 92

2 Answers2

26

Simply only use the - before and after your main section to surround it in lines, exclude the dash for the subsections, and then the method names will show as always.

#pragma mark - Public Methods -
#pragma mark Helper Methods
- (void)aMethod{}
#pragma mark Other Type of Methods
- (void)anotherMethod{}

#pragma mark - Private Methods -
#pragma mark Some Type of Method
- (void)aPrivateMethod{}

enter image description here

Joe
  • 56,979
  • 9
  • 128
  • 135
1

You can use any of these combinations:

  1. Hyphen before Description - Puts a separator above the description

#pragma mark - Description

  1. Hyphen after Description - Puts a separator below the description

#pragma mark Description -

  1. Hyphen before and after Description - Puts a separator above and below the description

#pragma mark - Description -

screenshot

Also, if you just want separators and no descriptions, simply use #pragma mark or #pragma mark -.

Iulian Onofrei
  • 9,188
  • 10
  • 67
  • 113
akshay1188
  • 1,647
  • 2
  • 17
  • 35