I’ve never considered this a problem, until I ran the Xcode “Analyze” feature. Say I have a class called dude and I have created an instance of class and synthesized it so self.dude is available.
This works just fine. However, in the dealloc if I put:
[self.dude release];
I get an Analyzer warning because really what it should be is:
[dude release];
However, this spawns another warning, as Analyzer thinks I am sending the release to the class name, not to the ivar.
Now, if the ivar is named something different than the class, there is no problem and [ivar release]; works without Analyzer warnings.
Should I take this as a general indication that it is not wise to name an ivar the same as a class name? It has never interfered with my product compilation or execution, but the Analyzer opens new questions about this.
You should start you class names with uppercase letters (
Dude) and instance variables (and other variables for that matter) with lower case letters (dude). This avoids the problem entirely and you’d also be following the standard naming conventions for Objective-C.