File tree 2 files changed +69
-0
lines changed
2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ .DS_Store
Original file line number Diff line number Diff line change
1
+ #格式
2
+
3
+ ###代码缩进
4
+ 代码缩进使用4个空格字符。
5
+
6
+ ###行宽
7
+ 一行代码尽量控制在80个字符内。这不是强制要求,只要不影响阅读即可。
8
+
9
+ ###方法的定义
10
+ \- 和 + 后留一个空格,方法参数名前留一个空格。参数名必须写,不留多余的空格。
11
+
12
+ - (void)doSomethingWithString:(NSString *)theString {
13
+ ...
14
+ }
15
+
16
+ 如果参数过多,一行内写不完时,每个参数应该独占一行,并保持冒号对齐。
17
+
18
+ - (void)doSomethingWith:(GTMFoo *)theFoo
19
+ rect:(NSRect)theRect
20
+ interval:(float)theInterval {
21
+ ...
22
+ }
23
+
24
+ 当第一个参数名太短时,后面的参数需要有适当的缩进(至少4个空格)。
25
+
26
+ - (void)short:(GTMFoo *)theFoo
27
+ longKeyword:(NSRect)theRect
28
+ evenLongerKeyword:(float)theInterval
29
+ error:(NSError **)theError {
30
+ ...
31
+ }
32
+
33
+ ###方法调用
34
+ 如果能在一行内写完则把所有参数写在同一行,不留多余的空格。
35
+
36
+ [myObject doFooWith:arg1 name:arg2 error:arg3];
37
+
38
+ 如果参数过多,一行内写不完时,每个参数应该独占一行,并保持冒号对齐。
39
+
40
+ [myObject doFooWith:arg1
41
+ name:arg2
42
+ error:arg3];
43
+
44
+ 当第一个参数名太短时,后面的参数需要有适当的缩进(至少4个空格)。
45
+
46
+ [myObj short:arg1
47
+ longKeyword:arg2
48
+ evenLongerKeyword:arg3
49
+ error:arg4];
50
+
51
+ ###protocol
52
+ protocol名称和类型之间不留空格。
53
+
54
+ @interface MyProtocoledClass : NSObject<NSWindowDelegate> {
55
+ id<MyFancyDelegate> _delegate;
56
+ }
57
+ - (void)setDelegate:(id<MyFancyDelegate>)aDelegate;
58
+ @end
59
+
60
+ --------------------
61
+
62
+ #命名
63
+
64
+ ###类名
65
+ 类名必须以大写字母开头,
66
+
67
+ #代码
68
+
You can’t perform that action at this time.
0 commit comments