当我编写一个有点复杂的方法时,我更喜欢在它上面添加一个小注释块
/*--------------------------------------------------------------+
| When I wrote this, only God and I understood what I was doing
| Now, God only knows
+-------------------------------------------------------------*/
- (void) overlyDifficultMethodToGrasp { ... }
真的这样,从我的代码中注释掉这个方法的唯一方法就是点击cmd + /
吗?哪会导致
///*--------------------------------------------------------------+
// | When I wrote this, only God and I understood what I was doing
// | Now, God only knows
// +-------------------------------------------------------------*/
//- (void) overlyDifficultMethodToGrasp { ... }
//
我想做的是
/*
/*--------------------------------------------------------------+
| When I wrote this, only God and I understood what I was doing
| Now, God only knows
+-------------------------------------------------------------*/
- (void) overlyDifficultMethodToGrasp { ... }
*/
正如您所看到的那样,它不起作用......
为什么?我觉得//
的大块很难看!
答案 0 :(得分:4)
这与Xcode没有太大关系,但与您使用的语言(和编译器)有关。您不能在C或Objective-C中使用嵌套的注释块。
答案 1 :(得分:3)
正如DrummerB指出的那样,你无法嵌套评论。
使用//代替/ *
的花哨评论这里:
/*
//--------------------------------------------------------------+
// When I wrote this, only God and I understood what I was doing
// Now, God only knows
//+-------------------------------------------------------------+
- (void) overlyDifficultMethodToGrasp { ... }
*/