Re: warning: local declaration hides instance variable
Re: warning: local declaration hides instance variable
- Subject: Re: warning: local declaration hides instance variable
- From: Shawn Erickson <email@hidden>
- Date: Mon, 03 Sep 2007 10:25:07 -0700
On Sep 3, 2007, at 10:13 AM, Tron Thomas wrote:
When I compile the following code:
#import <objc/Object.h>
#import <iostream>
@interface Value : Object
{
@private
int amount;
}
+ (Value*)valueWithAmount:(int)amount;
- (void)setAmount:(int)amount;
- (int)amount;
@end
- (void)setAmount:(int)amount
{
self->amount = amount;
}
The class method valueWithAmount emits no warning, yet the instance
method setValue emits something like:
Value.mm: In function 'void -[Value setAmount:](Value*,
objc_selector*, int)':
Value.mm:38: warning: local declaration of 'amount' hides instance
variable
This results indicates that the warning is wrong.
No the warning isn't wrong.
The instance variable was assigned the proper value.
Well only because you are accessing the ivar via struct reference.
-Shawn
_______________________________________________
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