I am looking to acquire information about how Objective-C identifies an entity in a program. How many characters are allowed, etc. I have tried to Google it, but I couldn’t come up with anything. Since it was party based on C, does the naming/binding/scope follow that of C? Any help would be appreciated. If you have any links that talk about these things it would also be helpful. Thanks in advanced.
I am looking to acquire information about how Objective-C identifies an entity in a
Share
Objective-C follows the same rules as C, then adds a couple of its own for the OO features not found in C.
As in C, there is no hard limit on the number of characters you can have in a variable name.
Scope and visibility rules are the same as in C, although Objective-C objects are almost always accessed through pointers — and the lifetime of the objects themselves are managed either through reference counting or garbage collection — so scope is somewhat less important than in C or C++.
The one major difference is that instance variables are scoped to the instance that they belong to, and you can control whether outside callers can access them with the
@public,@protectedand@privatekeywords.One other kinda-difference is blocks. They’re a nonstandard† addition to C that Apple has made. Blocks capture the scope around them, keeping things around as long as the block exists. Blocks also normally retain objects they reference to make sure those objects don’t get released. You can read about the specifics in Apple’s block programming guide.
†Apple has submitted blocks for standardization, but it hasn’t happened yet and may never actually happen, though it would be pretty nice if it did.