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 7192581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:58:12+00:00 2026-05-28T19:58:12+00:00

hello a noob question here. during my studies I was repeatedly instructed to always

  • 0

hello a noob question here.

during my studies I was repeatedly instructed to always specify a =_propertyName variable when @synthesize-ing a @property

so for example for

@property (nonatomic, strong) NSTimer *myTimer;

I would do

@synthesize myTimer = _myTimer;

now my question is. does this have to be done for IB properties as well ?
such as

@property (nonatomic, strong) IBOutlet UILabel *myLabel;
@property (nonatomic, strong) IBOutlet UIButton *myButton;

do I just do here:

@synthesize myLabel;
@synthesize myButton;

or:

@synthesize myLabel=  _myLabel;
@synthesize myButton = _myButton;

Now I can see, why this is useful for something like an NSArray, or NSString or BOOL where you’re actually storing some values, but I am not sure how/if this logic applies to UIButtons, UILabels and similar. Thank you for any pointers (no put intended)

  • 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-05-28T19:58:13+00:00Added an answer on May 28, 2026 at 7:58 pm

    It is a matter of preference. There is a difference that you should keep in mind, however, as far as scope. For example, if you write your synthesizer like this,

    @synthesize myTime = _myTime;
    

    And you are within the scope of an instance method of the class, for example, -(void)setTime:(id)myTime;, there is a difference between calling,

    self.myTime = newTime;
    

    And,

    myTime = newTime;
    

    It becomes clear that the first changes the instance variable of your object, and that the second reassigns the myTime local variable passed in as an argument to the method setTime:, which is something you usually don’t want to do. However, if you synthesized your instance variable like this,

    @syntehsize myTime;
    

    It is a little more confusing what would happen with this assignment,

    myTime = newTime;
    

    This actually reassigns the local variable, and may not be what you intended. So in naming your variables it is good to stick to conventions and try to avoid confusion. That is why it is my personal preference to assign the underscore and always set instance variables by calling them attached to self.

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

Sidebar

Related Questions

I have a noob question here. I'm getting my head around the C++ structure
Question: Hello All, Sorry that this is kind of a noob question. I just
Hello and thank you in advance. I know this is total noob question, and
hello i have one very NOOB question and i want to know the answer.
A noob question. if i have a string @Hello i am a string. is
This is a very noob question. I'm basically just trying to run the hello
I'm a noob at C/C++ So excuse the simplicity of the question, but here
Apologies up front for the noob question... Hello, how do I get data from
Hello i'm rely stuck here, Ok i already have a working function to update
Hello , I am using arshaw fullcalendar v1.5.2 (only month view ) for property

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.