Objective-C中的單個下劃線顯然是爲Apple的「內部」使用保留的(並且可以在Apple聲明之前與私有實例變量一起使用)。但爲什麼他們會在iPhone的SQLiteBooks示例中使用double -underscore?看到這個片段來自MasterViewController.m採取:Cocoa中的這種雙下劃線是什麼
+ (EditingViewController *)editingViewController {
// Instantiate the editing view controller if necessary.
if (__editingViewController == nil) {
__editingViewController = [[EditingViewController alloc] initWithNibName:@"EditingView" bundle:nil];
}
return __editingViewController;
}
有這個forum的雙下劃線使用提,因爲它涉及到C - 這是對「compier內部使用。」我想我沒有看到在這種情況下如何適用。
我需要一個ViewController在我的應用程序中表現得非常像SQLiteBooks示例項目中的一個,但是這種雙下劃線讓我感到困惑。
那麼你是說現在Apple已經聲稱它已經被內部使用,現在它已經被替換掉了一個下劃線? – Meltemi 2009-02-19 18:46:02
這忽略了問題的實際問題。 – 2009-02-19 18:46:33
是的,它和Apple的單下劃線一樣。 (不,安德魯,我不相信自己錯過了這一點,他問他們爲什麼使用雙下劃線,我解釋過。) – Chuck 2009-02-19 18:52:53