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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:01:00+00:00 2026-05-18T05:01:00+00:00

I’m certain that I’m missing some fundamental understanding of iOS memory management and, despite

  • 0

I’m certain that I’m missing some fundamental understanding of iOS memory management and, despite lots of reading and searching, I’m still not getting it.

I use a singleton in my app that has info about the user currently signed into it, info accessed from multiple view controllers, etc. It has multiple ivars that are get and set throughout the app. They’re declared and propertied in the .h file like so:

NSString *myString;

and are made retained like so:

@property (non atomic, retain) NSString *myString;

and synththesized in the implementation.

I get and set their values in methods in the singleton like this:

myString = @"value";

and

methodLocalString = myString;

In other places I include the singleton — call it CurrentUser — I import it:

#import "CurrentUser.h"     

Outside of the singleton I get and set it like this:

[CurrentUser sharedCurrentUser].myString = @"Bob";

and

myOutsideString = [CurrentUser sharedCurrentUser].myString;

Most of the time this works great, with the values appropriately persisted from one getting or setting to another. The trouble is that sometimes when I get them that way I find that they’ve been released (crashing the app), which NSZombieEnabled thankfully tells me.

What I don’t get is how his can happen. I thought the singleton was never released, and that therefor retained properties of the singleton would never be released. I’ll note that the problem seems to be more common with non-real-object properties like NSDate and definitely-not-object properties like int and BOOL which can’t be retained, but it happens with object properties as well.

What am I ignorant about here? And thanks for your patience.

  • 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-18T05:01:01+00:00Added an answer on May 18, 2026 at 5:01 am

    Your problem is:

    I get and set their values in methods
    in the singleton like this:

    myString = @"value";

    When you assign directly to the iVar, instead of using the property syntax (self.myString = @"value"), you are bypassing the synthesized setter method, which means that the retain never happens.

    Properties aren’t magic. They’re just a bit of syntactic sugar for the “.” access, and the ability to have synthesized getter/setter methods to save you the tedium of writing your own.

    self.myString = @"value";
    

    is just shorthand for

    [self setMyString:@"value"];
    

    The synthesized setMyString method will do something like:

    if (myString != newValue) {
        [myString release];
        myString = [newValue retain];
    }
    

    (assuming retain option on the @synthesize)

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I am doing a simple coin flipping experiment for class that involves flipping a

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.