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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:54:26+00:00 2026-06-12T02:54:26+00:00

Note: I am not using ARC I have a UILabel with the following property:

  • 0

Note: I am not using ARC

I have a UILabel with the following property: @property (nonatomic, retain) UILabel *someLabel; I am trying to set a custom setter. Would the following code cause a leak, since @property is actually calling retain as well?

- (void)setSomeLabel:(UILabel *)someLabel
{
    if (someLabel != self.someLabel) {
        [self.someLabel release];
        self.someLabel = [someLabel retain];
    }

    // some custom code here
}
  • 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-12T02:54:27+00:00Added an answer on June 12, 2026 at 2:54 am

    Note: I am not using ARC

    You really, really should.


    Your setter is an infinite loop. The call to self.someLabel = ... is the exact equivalent of [self setSomeLabel:...], which causes the loop.

    A correct manual setter looks like this:

    - (void)setSomeLabel:(UILabel *)someLabel
    {
      [someLabel retain];
      [_someLabel release];
      _someLabel = someLabel;
    
      // some custom code here
    }
    

    There are other common patterns. A major question is whether “some custom code” should run if the object is reset to the same value. If not, then this pattern makes more sense:

    - (void)setSomeLabel:(UILabel *)someLabel
    {
      if (someLabel != _someLabel) {
        [_someLabel release];
        _someLabel = [someLabel retain];
    
        // some custom code here
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a custom control inherited from WebControl. (Note: not a user control). using
( Note : I'm using Scala 2.7.7 here, not 2.8). I'm doing something pretty
Note - I do not have access to a database and cannot use PHP,
I have a base class line which has a child class arc (note that
Note: Not a duplicate of Why does Clojure recur think it should only have
I'm trying to upgrade my iOS project to using ARC. When starting the conversion
I am using urllib (note not urllib2) and getting title of pages from user
I get this note Call Not Sent when using the below code in android
Is it possible? Please note I am not using LINQ nor Entity Framework.
I have a leak in the following code which uses GCD. Note: I am

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.