• 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: Tron Thomas <email@hidden>
  • Date: Mon, 03 Sep 2007 13:44:11 -0700

Laurence Harris wrote:
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
When I'm programming in C++ I'm always in the habit of declaring member variables with an "m_" prefix. Placing an "m" or "m_" before a variable doesn't really seem to be a convention in Objective-C. Most people when they declare an Interface Building outlet don't prefix the outlet name with anything, and the outlets available from Cocoa class don't prefixes either. The outlets basically show up as public instance variables in the class declaration.

It seems inconsistent for some member to have a prefix and some to not have the prefix. For this reason, I tend to avoid prefixing Objective-C member variables that way.
_______________________________________________
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: Laurence Harris <email@hidden>
References: 
 >warning: local declaration hides instance variable (From: Tron Thomas <email@hidden>)
 >Re: warning: local declaration hides instance variable (From: Wincent Colaiuta <email@hidden>)
 >Re: warning: local declaration hides instance variable (From: Laurence Harris <email@hidden>)

  • Prev by Date: Getting rid of Obj-C "may not respond to" warning
  • Next by Date: Re: Getting rid of Obj-C "may not respond to" warning
  • Previous by thread: Re: warning: local declaration hides instance variable
  • Next by thread: Re: warning: local declaration hides instance variable
  • Index(es):
    • Date
    • Thread