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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:29:02+00:00 2026-05-24T17:29:02+00:00

I have an NSMutableArray , purDesc , that holds an NSMutableDictionary , purDetails .

  • 0

I have an NSMutableArray, purDesc, that holds an NSMutableDictionary, purDetails. When I use NSLog(@"%@", purDesc); it returns empty spaces where there should be dictionarys as follows:

singleton purDesc Dump:(
        {
    },
        {
    },
        {
    },
        {
    },
        {
    }
)

Now the size/look/dump changes every time I add a dictionary to reflect the number of times a dictionary gets added/removed. Here are the code snippets taken from my XML parser:

…

else if ([elementName isEqualToString:@"purDesc"])
{
    //close purDisc
    // dumps dictionary into log
    NSLog(@"End of purDesc");
    NSLog(@"Dump:%@", [purDesc description]);

    [singleton setPurDesc:purDesc];//sets this response to the response in the singleton

    NSLog(@"singleton purDesc Dump:%@", [[singleton purDesc] description]);
    return;//we're done here
}
else if ([elementName isEqualToString:@"PurDetails"])
{
    //close purDetails
    // dumps dictionary into log
    NSLog(@"End of PurDetails");
    [purDetails addEntriesFromDictionary:description];//sets current purDetails to current description
    NSLog(@"Dump:%@", [purDetails description]);

    [purDesc addObject:purDetails];//adds purDetails dictionary to purDesc
    [purDetails removeAllObjects];
    NSLog(@"Current purDesc:%@", [purDesc description]); 
}

What am I doing wrong and why is the log coming up semi-empty?

  • 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-24T17:29:03+00:00Added an answer on May 24, 2026 at 5:29 pm

    I see that you do:

    [purDesc addObject:purDetails];//adds purDetails dictionary to purDesc
    [purDetails removeAllObjects];
    

    That stores a reference to purDetails in purDesc, and increments its retain count, but it does not make a copy. So if you removeAllObjects, the contents of the dictionary are lost. The fact you “stored” a reference to it in purDesc doesn’t change that. I guess what you see is the result of this or a similar action.

    You can’t re-use the dictionary. You’ll have to alloc and init a new one each time. You should release the local one you have, but not clear it.

    I’d need to see more code to see how you can improve your design thus that this is not a problem and memory management is taken care of properly.

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

Sidebar

Related Questions

Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
I have a NSMutableArray that holds a collection of UIViewControllers Amongst other properties and
I have a NSMutableArray (tripHistory) that gets a NSMutableDictionary (currentUpdate) added to it every
I have an NSMutableArray that holds multiple and changing amounts (that's why I am
I have a NSMutableArray: NSMutableArray *temp = //get list from somewhere. Now there is
I have an NSMutableArray that is populated with objects of strings. For simplicity sake
I have a NSMutableArray that I need to search for a string and return
I have a class that subclasses NSMutableArray. I init it using: MyClass class =
I have NSMutableArray *myArray = nil; . If I will use [myArray insertObject:@Hello atIndex:0]
I have an NSMutableArray that contains many NSArrays. At a specific (static) index in

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.