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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:51:48+00:00 2026-05-28T00:51:48+00:00

Ok, I spent the last 8 hours fighting with it – it just seems

  • 0

Ok, I spent the last 8 hours fighting with it – it just seems beyond me. Here’s my complete (relevant) code:

- (void)updateUserDefaults
{
    NSMutableDictionary *viewControllerDetails = [[NSMutableDictionary alloc] initWithCapacity:4];

    [viewControllerDetails setObject:[NSNumber numberWithInt:OOVenueClassControllerType] forKey:@"classType"];
    [viewControllerDetails setObject:self.searchTerm forKey:@"searchTerm"];
    [viewControllerDetails setObject:self.searchLocation forKey:@"searchLocation"];

    //----- the next two lines cause the problem
    NSString *res = [[NSString stringWithFormat:@"%@",[searchResults xmlString]] retain];
    [viewControllerDetails setObject:res forKey:@"searchresults"];
    //-----

    NSMutableArray *viewControllersList = [NSMutableArray array] ;
    [viewControllersList addObject:viewControllerDetails];

    NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
    //the following line causes the error
    [defs setObject:viewControllersList forKey:kViewControllersKey];
    [defs synchronize];

    [res release];
}

Note the block with the next two lines cause the problem. At first I didn’t create another string, but added it later while trying to solve the problem.

If I comment out those two lines, everything works fine. If I put them back in, I get

- [CFString class]: message sent to deallocated instance 0xa1a9000

Is something is wrong with the string that I’m trying to put into the userdefaults? That string is rather large (about 200,000 characters), but I had stored even longer strings in user defaults in the past.

It’s also worth noting that if I uninstall the app, then everything works fine. But on subsequent runs the problem exhibits itself.

So, how and why and where is the string getting deallocated? I have explicitly added retain – but that still doesn’t help. What am I missing?

Edit: just realised I forgot to say that the error is thrown on line

[defs setObject:viewControllersList forKey:kViewControllersKey];

Also, for general information, method - (NSString *)xmlString on searchResults does exactly what the name means: creates an XML string with the information from that object.

Edit 2: I tried doing something else with that string – convert it to NSData, compress using zlib – but regardless of data type, that particular object gets deallocated. Does it have to do something with the size of the string?

  • 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-28T00:51:49+00:00Added an answer on May 28, 2026 at 12:51 am

    Ok, not sure what exactly the problem was, but it was somewhere in the searchResults and/or xmlString method. searchResults object is originally created from XML received from the server (XML is parsed into the object structure). When xmlString was called, for some reason the string I was getting back was different from the original XML (I’m not talking about formatting, of course) – of 200,000 char-long string, within the first 500 chars or so there were some differences. I haven’t been able to figure out why. So, instead of recreating the xml from object structure, I instead stored the original XML in a field in that object and, when xmlString was called, simply returned the original string. Now everything worked fine.

    Thank you all for your support through this painful process.

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

Sidebar

Related Questions

i've just spent the last 4 hours working on this piece of code and
I have spent last couple of hours searching for answers here but nothing seems
So I just spent the last few hours pouring over code trying to figure
i spent last few hours trying to find what is wrong in my code(?)
I've been having problems with this code I had spent the last 3 hours
I just spent the last 7 hours straight trying to find a way to
I have spent the last 3 hours trying to get this code working. I
Okay, I just spent the last four hours trying to figure out why my
So i spent the last hour or so fighting with my code, and eventually
I just spent the last 3 hours trying to figure out this error. I

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.