The MARK: Keyword

I see some posts about the MARK: keyword and that it will show code below it somewhere, I put this keyword above a line of code but nothing happen and cant see it anywhere ?

--

Kindest Regards

Answered by DelawareMathGuy in 411305022

hi,


MARK can be used in conjunction with comment syntax to separate out portions of your code so you can navigate easily in your code using the pull-down at the top of the XCode window.


for example, you might group all the life cycle code for a UIViewController this way, followed by methods for certain other tasks:


// MARK: - Lifecycle

override func viewDidLoad() {
// your code
}

override func viewDidAppear(_ animated: Bool) {
// your code
}

// MARK: - Photo Handling

func takePhoto(_ sender: Any) {
// your code
}

func editPhoto() {
// your code
}


in XCode 11, you'll see a horizontal line drawn across the screen to visually enforce this grouping, and you'll see the MARK phrases ("LifeCycle", "Photo Handling", and so forth) in large type in the Minimap.


hope this helps,

DMG

Accepted Answer

hi,


MARK can be used in conjunction with comment syntax to separate out portions of your code so you can navigate easily in your code using the pull-down at the top of the XCode window.


for example, you might group all the life cycle code for a UIViewController this way, followed by methods for certain other tasks:


// MARK: - Lifecycle

override func viewDidLoad() {
// your code
}

override func viewDidAppear(_ animated: Bool) {
// your code
}

// MARK: - Photo Handling

func takePhoto(_ sender: Any) {
// your code
}

func editPhoto() {
// your code
}


in XCode 11, you'll see a horizontal line drawn across the screen to visually enforce this grouping, and you'll see the MARK phrases ("LifeCycle", "Photo Handling", and so forth) in large type in the Minimap.


hope this helps,

DMG

AT the very top of a code pane in XCode, you have a line that looks like :

< > MyApp > level1 > level2 > P SomeName

If you click on SomeName, you get a popup

The content of MARK appears as a separator line in the list of declarations (var and func)

Thanks allot

The MARK: Keyword
 
 
Q