mk12
mk12

Reputation: 26404

Xcode - Using #pragma mark

I'm pretty sure this isn't a duplicate. Do you use #pragma mark? I've seen multiple ways, which is correct?

#pragma mark -
#pragma mark === Actions ===
#pragma mark -

#pragma mark -
#pragma mark === Actions ===

#pragma mark - === Actions ===

#pragma mark Actions

What is the way you do it? How do you suggest dividing it up? What do you normally name your sections, for say, a view controller?

Upvotes: 22

Views: 16965

Answers (2)

Denis Kozhukhov
Denis Kozhukhov

Reputation: 1215

if use like this

#pragma mark -
#pragma mark Actions

or this

#pragma mark - Actions

xcode will add one separator and bold text line Actions.

BUT if you add one more space after minus - xcode will create two separators one by one...

#pragma mark -SPACEHERE
#pragma mark Actions

:)

Upvotes: 2

Louis Gerbarg
Louis Gerbarg

Reputation: 43452

There is no "Correct" way, it is annotation, so how you use it is a coding style issue.

Having said that, I do:

#pragma mark -
#pragma mark Actions

Because that causes the popup menu in the Xcode editor group the title and the methods inside of the same divider.

Upvotes: 39

Related Questions