• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: warning: local declaration hides instance variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: warning: local declaration hides instance variable
      • From: Tron Thomas <email@hidden>
References: 
 >warning: local declaration hides instance variable (From: Tron Thomas <email@hidden>)

  • Prev by Date: warning: local declaration hides instance variable
  • Next by Date: Re: warning: local declaration hides instance variable
  • Previous by thread: warning: local declaration hides instance variable
  • Next by thread: Re: warning: local declaration hides instance variable
  • Index(es):
    • Date
    • Thread