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

  • Home
  • SEARCH
  • 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 8091113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:57:34+00:00 2026-06-05T19:57:34+00:00

many Places in the sample code i have seen 2 different way of @synthesize

  • 0

many Places in the sample code i have seen 2 different way of @synthesize variable. For Example here i am taking 1 sample button.
@property (strong, nonatomic) IBOutlet UIButton *logonButton;

1.@synthesize logonButton = _logonButton;

2.@synthesize logonButton;

among this 2 methods which one is recommended?

  • 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-05T19:57:36+00:00Added an answer on June 5, 2026 at 7:57 pm

    Short Answer

    The first method is preferred.

    Long Answer

    The first example is declaring that the generated ivar for the logonButton property should be _logonButton instead of the default generated ivar which would have the same name as the property (logonButton).

    The purpose of this is to help prevent memory issues. It’s possible that you would accidentally assign an object to your ivar instead of your property, and it would then not be retained which could potentially lead to your application crashing.

    Example

    @synthesize logonButton;
    
    -(void)doSomething {
        // Because we use 'self.logonButton', the object is retained.
        self.logonButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    
        // Here, we don't use 'self.logonButton', and we are using a convenience
        // constructor 'buttonWithType:' instead of alloc/init, so it is not retained.
        // Attempting to use this variable in the future will almost invariably lead 
        // to a crash.
        logonButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to java, I have seen in the code at many places
In many places in our application we have code like this: using(RAPI rapi =
I have the code below in my test code in many places: // //
I have read in many places that WPF combo does not support autocomplete but
I have used the conditional operator in many places within my Java application. Now
I have a new website that is linked to from many places but the
I have a sample code wherein: I am unable to understand how data flows
I have read in many places that network connection in a j2me app should
There are many places in my application where I need to generate links with
I've read advice in many places to the effect that sending a lot 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.