-1

I'm working on an iOS Project, in which I'm using #pragma mark to arrange methods according to their respective category.

My issue is that some categories have sub-categories. How can I arrange my methods to reflect method categories and their subcategories? Is this even possible?

I need something like:

Pragma Sub

I've tried:

  • This:
#pragma mark - Main
#pragma mark -  Sub 1
#pragma mark -   Sub of Sub 1
  • And this:
#pragma mark - Main
#pragma mark -- Sub 1
#pragma mark --- Sub of Sub 1

Neither work. I've searched a lot, but couldn't find any solution. Is there any way to do this?

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • Maybe escaping (`\ `) the whitespace will work? – akashivskyy May 20 '13 at 13:42
  • @akashivskyy: Thanks for your comment :) I tried this but the category will display a (`\`) before the category name :( – Midhun MP May 20 '13 at 13:45
  • 2
    Is the desire for sub-categories a symptom of a class that's becoming a god-class? Time to split it up? Even if you need a single class for some reason, you can modularise with obj-c categories to put different functionality of a single class into seperate files. – Steve Waddicor May 20 '13 at 13:47

4 Answers4

0

Simply remove the dash from the subcategory and it will be placed under the main

#pragma mark - Main
#pragma mark  Sub 1
Mark McCorkle
  • 9,349
  • 2
  • 32
  • 42
0

You can not have spaces after the the #pragma mark. So there is no way for this type of structure as you need using pragma.

Hope it helps you.

Nishant Tyagi
  • 9,893
  • 3
  • 40
  • 61
0

Answer : I don't think so , it's possible exactly what you are looking for.

As Apple has already provided "Collapsing Methods" concept for it. When you need to see more than one part of your code at once, Xcode lets you close and open method groups. Place your mouse in the gutter directly to the left of any method. A pair of disclosure triangles appears. Click a triangle, and Xcode collapses the code for that method.

enter image description here

The ellipsis indicates the collapsed method. Click the disclosure triangle, and Xcode reveals the collapsed code. You can also collapse any compound statement.

I found something for you : Is it possible to have a hierarchy of “#pragma mark” ?

Community
  • 1
  • 1
Bhavin
  • 27,155
  • 11
  • 55
  • 94
0

Use Option-Space to insert unbreakable spaces in your source code instead of regular spaces. They will be preserved in the menu. (They will appear as dots in the source.)

Guillaume
  • 4,331
  • 2
  • 28
  • 31