Re: warning: local declaration hides instance variable
Re: warning: local declaration hides instance variable
- Subject: Re: warning: local declaration hides instance variable
- From: Laurence Harris <email@hidden>
- Date: Mon, 3 Sep 2007 14:52:50 -0400
On Sep 3, 2007, at 1:31 PM, Wincent Colaiuta wrote:
El 3/9/2007, a las 19:13, Tron Thomas escribió:
@interface Value : Object
{
@private
int amount;
}
+ (Value*)valueWithAmount:(int)amount;
You have a instance variable called "amount" and a method-local
variable called "amount" which hides it. Pick a different name for
your "amount" parameter in the valueWithAmount: method. For
example, "anAmount", or anything else.
An even better solution would be to rename your instance variables
with a standard naming convention that clearly identifies them as
instance variables. Since they're also referred to as member
variables, a lot of people prefix their names with an "m":
@interface Value : Object
{
@private
int mAmount;
}
Given how helpful this is I can't imagine not using a naming
convention that immediately differentiates local and instance
variables. A naming convention to differentiate parameters is also
helpful.
Larry _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden