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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:03:39+00:00 2026-06-12T17:03:39+00:00

I was quickly going over a large project looking for memory leaks, and came

  • 0

I was quickly going over a large project looking for memory leaks, and came across a @property (nonatomic, retain) without a corresponding release in dealloc. Oops, quick fix, I think.

After a later crash, I look closer and the setFoo method is overriden, and the value is being retained but not by the ivar – for the sake of this question, assume it’s being put into an NSDictionary.

(OK, if you don’t want to assume that – the set value is actually a CCSprite in cocos2d, setNormalSprite, and it is being added as a child, thus retained, but simply assigned to the ivar:

 - (void)setNormalSprite:(CCSprite *)sprite 
  {
    if (normalSprite) {
        [self removeChild:normalSprite cleanup:YES];
        normalSprite = nil;
    }

    normalSprite = sprite;
    [self addChild:normalSprite];

    (...omitted...)
   }

)

What is the correct keyword for a value whose setter causes the retain count to increase, but not because the ivar it’s associated with is retained?

  • 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-12T17:03:40+00:00Added an answer on June 12, 2026 at 5:03 pm

    retain (or strong in ARC world) is correct in your case because you’re adding your CSSprite object into another collection that retains the object.

    You should set the @property to @dynamic in your @implementation too if you are not actually using an instance variable to store the object.

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

Sidebar

Related Questions

I quickly wrote an interpreter for some sort of experimental programing language i came
I'm looking to be able to build GUI applications quickly and painlessly as possible.
We have been going through a big memory leak analysis and have found one
I'm building a Rails app that is probably going to have a large amount
I am soon to join a PHP project that has been developed over the
E.g. dropdown menu if yo render it and quickly mouse over the about us
For quickly mocking up UI, I'd like to be able to drag buttons onto
I would like to (quickly) determine if one array contains all the elements of
Is it possible to quickly hide what's on a particular monitor in Visual Studio?
Can this be done quickly in jQuery before I start looping through them? Or

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.