Reputation: 24750
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.
Upvotes: 0
Views: 97
Reputation: 45598
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.
Upvotes: 3
Reputation: 34185
It definitely is not a common practice to start a class name with a lower case letter. Objective-C/Cocoa convention is that you start a class name with a capital, and the method name and the instance variable name with a lower case letter.
Just follow the common practice and name your class Dude
and name your ivar dude
.
Upvotes: 0