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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:53:58+00:00 2026-05-25T01:53:58+00:00

I am stuck debugging a NSInvalidArgumentException. My latest suspicion is that I didn’t retain

  • 0

I am stuck debugging a NSInvalidArgumentException. My latest suspicion is that I didn’t retain the data read from plist properly so that it’s occupied by some other object while I access it.

My plist structure is very complicated, it has 8 levels of arrays/dictionaries. I think I lost the memory when I try to access the lowest object.

I wonder if I have to retain every data element when I read the plist file or is it sufficient to just retain the top level object?

This is how I read:

NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
NSError *error = [[[NSError alloc] init] autorelease];
NSArray *temp = (NSArray *)[[NSPropertyListSerialization
                            propertyListWithData:plistXML 
                            options:NSPropertyListMutableContainersAndLeaves
                            format:nil 
                            error:&error] retain];
self.dataPackage = [temp objectAtIndex:0];

dataPackage is declared as:

@interface rootViewController:UIViewController{
  NSDictionary *dataPackage;
}
@property (retain) NSDictionary *dataPackage;

and synthesized:

@synthesize dataPackage;

Am I doing it right?

Thanks

Leo

  • 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-25T01:53:59+00:00Added an answer on May 25, 2026 at 1:53 am

    I noticed 3 things:

    • You don’t need to create an NSError object! NSPropertyListSerialization will return an error object if something fails. Just init with: NSError *error = nil;

    • You don’t have to retain the (autoreleasing) temp-array, you obviously don’t need the whole array after fetching the object at index 0.

    • [temp objectAtIndex:0] will crash when the array is empty!

    Be sure to release the property var in dealloc with self.dataPackage = nil. Then everything is safe from memory management perspective.

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

Sidebar

Related Questions

Debugging my code with Java's jdb. Am stuck at a point where my program
I'm stuck after step 3 in trying to setup remote cross-debugging with Eclipse/RSE: Installed
Looking for tools for debugging n3. Are we stuck with using XML just because
I don't like real-time debugging much, but if it's necessary I'll do it. Is
I'm in the process of trying to move our company from SalesForce to SugarCRM,
I have an application I'm working on that uses two third party libraries, each
I am debugging an issue, where there is a thread which continues to run
While debugging my application with Delphi 2009, I sometimes get the following exception occurring:
I'm debugging an application on a remote server running JBoss using Eclipse. My particular
I am debugging an application which, in its message loop, calls IsDialogMessage() . Occasionally,

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.