當我將任何第三方的代碼到我的應用程序,我做的第一件事是重新格式化我的個人喜好編碼:你的Objective-C編碼風格是什麼?
// Single line comments only
// I never put spaces inside my parenthesis
-(void)myOCDMethod
{
// If an if or for statement has only one instruction, I don't use brackets
if(this)
[self that];
else
[self somethingElse];
// If I do have to use brackets, they go on their own lines so that they line up
if(this)
{
[self that];
[self andThat];
}
// I always put the pointer asterisk next to the instance name
NSObject *variable = [[NSObject alloc] init];
// I always put spaces around operators
if(i == 0)
x = 2;
}
你用什麼OCD編碼格式?
我相信,不使用括號也會編譯更簡單的指令。不應該在每天的基礎上顯着,但總是很高興知道你在幫助。 爲什麼單行註釋? – 2008-11-27 01:32:54
編譯器爲什麼不能自行執行該優化?似乎微不足道...... – 2012-07-07 19:47:36
(同樣的問題適用於A?B:C;) – 2012-07-07 19:48:50