Search code examples
iosxcodeswiftpragma

In Xcode, How do I Suppress "MARK:" part of menu addition?


In Objective C, when using

// MARK: Line In Sand

The default project will produce a menu items with the word "MARK:" in it, or in other words:

Line In Sand showing MARK

Just recently I downloaded a sample project in Swift (vs ObjC) "ViewControllerPreview" from Apple and the // MARK: Line In Sand only showed "Line In Sand" (no "MARK") when using the aforementioned mark comment style. How'd they do that!? Is that just a basic improvement not applied to anything but Swift?

Mark not in menu!


Solution

  • In Objective-C, you can make a mark like that in two different ways:

    #pragma mark - Hack
    
    // MARK: HACK
    

    This will appear like so:

    mark

    In Swift, you only get // MARK, which is treated like a pragma mark.

    // MARK: Something
    

    Swift mark