【发布时间】:2010-10-08 16:07:17
【问题描述】:
Objective-C 中的单下划线显然是为 Apple 的“内部”使用而保留的(并且在 Apple 声明之前可用于私有实例变量)。但是为什么他们会在他们的 iPhone 的 SQLiteBooks 示例中使用 double-下划线呢?请参阅取自 MasterViewController.m 的这个 sn-p:
+ (EditingViewController *)editingViewController {
// Instantiate the editing view controller if necessary.
if (__editingViewController == nil) {
__editingViewController = [[EditingViewController alloc] initWithNibName:@"EditingView" bundle:nil];
}
return __editingViewController;
}
forum 上提到了双下划线的使用,因为它与 C 相关——它是为了“编译器的内部使用”。我想我看不出这在这种情况下如何适用。
我的应用程序中需要一个 ViewController,其行为与 SQLiteBooks 示例项目中的 ViewController 非常相似,但这个双下划线让我感到困惑。
【问题讨论】:
标签: objective-c cocoa double-underscore