2

When I write a method that is a bit complicated I prefer to add a little comment block above it as

/*--------------------------------------------------------------+
| When I wrote this, only God and I understood what I was doing
| Now, God only knows
+-------------------------------------------------------------*/
- (void) overlyDifficultMethodToGrasp { ... }

Is it really so that the only way to comment out this method from my code would be to hit cmd + /? Which would result in

///*--------------------------------------------------------------+
// | When I wrote this, only God and I understood what I was doing
// | Now, God only knows
// +-------------------------------------------------------------*/
//- (void) overlyDifficultMethodToGrasp { ... }
//    

What I would like to do is

/*
/*--------------------------------------------------------------+
 | When I wrote this, only God and I understood what I was doing
 | Now, God only knows
 +-------------------------------------------------------------*/
- (void) overlyDifficultMethodToGrasp { ... }
*/

Which, as you can see, doesn't work...

Why? Well I think large chunks of // are ugly!

jszumski
  • 7,430
  • 11
  • 40
  • 53
Groot
  • 13,943
  • 6
  • 61
  • 72
  • Also mind the documentation comments for different coloring. More info here: http://stackoverflow.com/questions/6605535/what-are-documentation-comments-in-xcode – Desdenova Apr 25 '13 at 14:05

3 Answers3

4

This has not much to do with Xcode, but with the language (and compiler) you're using. You can't have nested comment blocks like that in C or Objective-C.

DrummerB
  • 39,814
  • 12
  • 105
  • 142
3

As DrummerB pointed out, you can't nest comments.

Use // for the fancy comments instead of /*

here:

/*

//--------------------------------------------------------------+
// When I wrote this, only God and I understood what I was doing
// Now, God only knows
//+-------------------------------------------------------------+

- (void) overlyDifficultMethodToGrasp { ... }
*/
codrut
  • 810
  • 10
  • 19
0

It's possible to use a workaround for the lack of an easy nested comment shortcut. The workaround involves snippets.

First create a code snippet with /* newline */ (see shift + command + l).

Then multi-select the cursor above and under the lines of the comments you want to comment out.

Press shift + command + l, and select the snippet for nested comments in the Xcode library.

Make sure to select two cursors that wrap around the comment lines. That way, the snippet will automatically place the two parts of the snippets (/* and */) exactly around your comments.

Cihan
  • 69
  • 1
  • 3