Search code examples
iosobjective-cxcodepragma

Is there a way to minimize everything between two pragma marks


I don't think this one requires much sample code. But for the sake of completeness let's say I have this code.

#pragma mark    Getters / Setters

- (NSMutableDictionary *)myDict
{
    if (!_myDict)
    {
        _myDict = [[NSMutableDictionary alloc] init];
    }
    return _myDict;
}
 - (NSMutableDictionary *)anotherDict
    {
        if (!_anotherDict)
        {
            _anotherDict = [[NSMutableDictionary alloc] init];
        }
        return _anotherDict;
    }

#pragma mark    Designated Initializer
-(id)initWithName:(NSString *)name
{  
   if (name)
      _name = name;

    return self;
}

Let's say I have numerous getters and setters here and I want to hide all of them (especially in a case like this where I'm doing simple lazy instantiation). Is there a way to do that wholesale? Right now I'm simply compressing each method as that's all XCode seems to detect.


Solution

  • Not sure if there is a way to achieve it. Folding & unfolding the methods looks like an available option to me.

    Fold                       ⌥⌘←      option+command+left
    Unfold                      ⌥⌘→      option+command+right