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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:03:31+00:00 2026-06-02T16:03:31+00:00

I have built one ‘deep’ NSMutableDictionary that contains parsed XML data along with other

  • 0

I have built one ‘deep’ NSMutableDictionary that contains parsed XML data along with other relevant information that I can pass from one view controller to another. The NSMutableDictionary contains mostly NSStrings but also another NSMutableDictionary more NSStrings and finally followed even deeper with an NSMutableArray of custom objects (it’s for a calendar).

Now, because it is a calendar, there are obviously dates involved. The XML data that I receive and parse using NSXMLParser returns strings, so it was on me to convert the day’s date to usable numbers. The date in XML comes in with the following format: “MM.DD” I created the following method to do so:

- (void)createDateCodesWithString:(NSString *)string 
{ 
   NSInteger monthCode;
   NSInteger dayCode;
   ....
   NSArray *dates = [string componentsSeparatedByString:@"."];
   monthCode = [[dates objectAtIndex:0] integerValue];
   dayCode = [[dates objectAtIndex:1] integerValue];
   ....
   shortDay = [NSNumber numberWithInt:dayCode];
}

‘shortDay’ is a NSNumber* and an ivar and set as a property (nonatomic, retain) for the custom object that I have created. When I run NSLog commands in the console, it appears that ‘shortDay’ and other data has been stored successfully in the deep NSMutableDictionary. I run in to problems, however, when I try to access the data again. When I access a NSString* stored ivar, things work OK, but when I attempt to access the NSNumber* I am given the error EXC_BAD_ACCESS with either code 1 or code 2. This is how I try to call upon the NSNumber*

   NSNumber *number = day.shortDay;
   return [number stringValue];

Might the problem be because the NSArray *dates strips the string into month and day strings and the day string, being two characters long, may contain a ‘0’ before, say, a ‘6’ if the day is the 6th of the month? Any advice?

I am happy to post more code if needed.

  • 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-02T16:03:33+00:00Added an answer on June 2, 2026 at 4:03 pm

    It’s possible that the memory for shortDay is being cleaned up before the next time you try to access it. When assigning it, try this instead:

    shortDay = [[NSNumber numberWithInt:dayCode] retain];
    

    to increase the reference count (AKA take ownership of the object) to avoid the memory being deallocated too early.

    If this resolves the problem, you will then need to call [shortDay release] in the dealloc method of your class, such that the memory for it will be properly deallocated at the right time.

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

Sidebar

Related Questions

I have built a web application using Java EE platform that sells one of
Why should one go for Windows Installer XML (WiX) when we have in built
I have built a Twitter client that's only one page: index.html. When being used,
I have built a simple project called LibTest that has one class with the
I have built one windows service that sends out email after every 30 minutes
I have built a gridview that includes one bound column on the far left
I have built one web application and in that i had bound drop down
I have built 2 apps: one for iPhone, one for iPad. They both build
I have built CMS on cakephp framework. I can delete just one or more
Does Java have a built-in Antivirus? One of my friends told me there is

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.