Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8336229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:55:06+00:00 2026-06-09T03:55:06+00:00

This is a purely theoretical question: I have a class that has a variable:

  • 0

This is a purely theoretical question:

I have a class that has a variable: varX.
I have a method that changes this variable. Xcode, with autocompletion suggest:

-(void)setVarX:(float)varX;

In implementation, when I write the instance method, Xcode tells me a warning:

“Local declaration of ‘varX’ Hides instance variable”

the method:

-(void)setVarX:(float)varX {

    varX = varX;

}

So, to solve, I used the underscore in synthesize;

@synthesize varX = _varX;

and the method is:

-(void)setVarX:(float)varX {

    _varX = varX;

}

is proper to use the underscore before variables in this way? otherwise how do I use the name of the method suggested by Xcode?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:55:07+00:00Added an answer on June 9, 2026 at 3:55 am

    Xcode 4.4 (and later) have automatic synthesis of properties (so that @synthesize is not needed anymore) when you don’t use @dynamic. The automatic synthesis uses the underscore, so it seems that Apple wants this to be a convention.

    First, I disliked this idea, but now I see why it’s handy. Those variable names of those properties aren’t “reserved” anymore in more methods (I never use underscores in other situations).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is purely a theoretical question, I know that if someone declares a method
This is a purely theoretical question. Given three simple classes: class Base { }
This is a purely theoretical question, I know that the standard containers interface are
This is a purely theoretical 'what if' question, so no pressure to rush to
A Purely theoretical question on Tcl. Following this question I was thinking on what
Disclaimer: This question is meant to be purely theoretical, so please don't ask me
This is purely a theoretical question as I'm not sure the conditions to cause
First of all, this question is purely theoretical. Fact is, whether it's possible or
This question is purely theoretical. I was wondering whether the Linux source code could
So this is purely a question of curiosity... Say I have a set of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.