1

Possible Duplicate:
What is this double underscore in Cocoa

I've seen a variety of Core Data code examples that use two underscores instead of one. I am aware of the advantages of iVars and using _variableName...But is there a particular reason/advantage for using two instead of one? such as __fetchedResultsController = ...

Community
  • 1
  • 1
Eric Welander
  • 560
  • 4
  • 11

1 Answers1

5

There are no real reasons to use a double underscore.

I will say that I'm not a fan of them though, because some things in Objective-C use them, such as:

__block or __unsafe_unretained

When I see the __, I tend to think of it firstly as a decorator that Apple has defined. If anything, it adds an extra second of thought to it, whereas the single underscore is universally understood to be a class' iVar.

I'd suggest just using _.

From the accepted answer to "What is this double underscore in Cocoa?":

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.

A summary of the ANSI C standard says:

External identifiers beginning with an underscore are reserved for library usage.

Community
  • 1
  • 1
Josh
  • 12,448
  • 10
  • 74
  • 118