Neither the C compiler nor the Objective-C compiler treats variable names with leading underscores any differently than any other variable name. A single or double leading underscore is simply a convention and effectively forms a namespace, much like the NS
prefix used in Cocoa classes like NSString
.
Looking at the SQLiteBooks code, MasterViewController.m
defines this static global variable:
// Manage the editing view controller from this class so it can be easily accessed from both the detail and add controllers.
static EditingViewController *__editingViewController = nil;
So my guess is that the author of SQLiteBooks uses a double leading underscore to indicate a global variable.
C compilers (and by extension Objective-C) reserve names beginning with two underscores and a capital letter for use by the compiler vendor, giving them a reserved namespace to use for global variables and functions used to implement standard libraries, or to introduce new non-standard keywords like __block
.
While the SQLiteBooks code is technically valid, it's too easily confused with the reserved namespace in my opinion. If you do reuse that code, I'd recommend renaming that variable (Xcode has a very nice rename refactoring that will do it automatically for you).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…