Hi Brad,

On Mon, Apr 6, 2009 at 10:10 AM, Brad O'Hearne
<br...@bighillsoftware.com> wrote:

> I had a few questions about selectively suppressing a certain warning in
> Xcode. I personally find the warning which pertains to local variables
> hiding instance variables a real nuisance. For example, if you have a
> message signature with a parameter name which matches an instance variable
> name, and the compiler produces the following message:
>
> "warning: local declaration of '<variable name>' hides instance variable"
>
> Two questions:
>
> 1. I get the gist of trying to prevent developers from accidentally hiding
> variables -- but is this really a major problem? Other than this, is there a
> compelling reason to keep this warning in tact, and change variable
> parameter variable names to make the warning go away?
>
> 2. How do you get Xcode to not produce this warning?

I would urge you not to suppress the warning. It's easy enough to
change one of the names so that they don't clash and it's one more
potential bug (you type the name intending to get the value of the
instance variable but get the parameter instead) you don't have to
worry about.

A lot of people like to prefix their instance variables. Apple use an
underscore which I don't personally like to do because underscore
prefixes tend to be reserved. Other people use different prefixes but
I don't like doing that either because that can complicate things for
KVO and KVC (KVO and KVC know about underscore prefixes).

My personal preference is to prefix the parameter name with either
'a', 'an' or 'the' depending on the context.

If you insist on disabling the warning, "-Wno-shadow" will probably do
the trick. You'd have found that out by looking at the gcc man page.

Kind regards,

Chris
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to