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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:05:35+00:00 2026-05-19T13:05:35+00:00

According to the Google Objective-C Style Guide , we should autorelease then retain as

  • 0

According to the Google Objective-C Style Guide, we should autorelease then retain as so:

- (void)setFoo:(GMFoo *)aFoo {
  [foo_ autorelease];  // Won't dealloc if |foo_| == |aFoo|
  foo_ = [aFoo retain];
}

In this case, foo_ will not be deallocated if being set to the same instance, making for a more defensive setter.

My question is, is this how @property & @synthesize work?

  • 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-19T13:05:35+00:00Added an answer on May 19, 2026 at 1:05 pm

    release due to an autorelease isn’t called until the end of the current runloop so foo_ wont dealloc because retain is called first followed by release at the end of the current runloop. However, this isn’t how the code generated in @synthesize works. It works more like

    - (void)setFoo:(GMFoo *)aFoo {
       if (aFoo != foo_) {
          [aFoo retain];
          [foo_ release];
          foo_ = aFoo;
       } 
    }
    

    This method saves cpu cycles when no change is necessary and takes out the small overhead of using the autorelease pool.

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

Sidebar

Related Questions

According to docs at http://code.google.com/p/minify/wiki/UriRewriting $min_serveOptions['rewriteCssUris'] = false; I should be able to add
I have my google news sitemap, which according to google's spec, should contain articles
I am working with google map. According to requirements i need to set different
According to Google search: since MySQL does not support full outer join, it could
According to this: http://code.google.com/appengine/docs/whatisgoogleappengine.html it seems that GAE only uses Datastore to store data,
According to Google Analytics : The total combined length of any custom variable name
Is Eventbus more a Mediator or an Observer? According to Google, eventbus mediator gets
According to Google Mail guidelines , bulk mail must contain the header Precedence: bulk
According to Google to allow your article/news to appear in Google News: Display a
According to Google , App Engine replenishes its quota at midnight, Pacific time. It's

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.