#pragma mark in Swift?

Arbitur picture Arbitur · Jun 3, 2014 · Viewed 228.2k times · Source

In Objective C, I can use #pragma mark to mark sections of my code in the symbol navigator. Since this is a C preprocessor command, it's not available in Swift. Is there a stand-in for this in Swift, or do I have to use ugly comments?

Answer

Frank Schmitt picture Frank Schmitt · Jun 4, 2014

You can use // MARK:


There has also been discussion that liberal use of class extensions might be a better practice anyway. Since extensions can implement protocols, you can e.g. put all of your table view delegate methods in an extension and group your code at a more semantic level than #pragma mark is capable of.