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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:04:17+00:00 2026-06-17T18:04:17+00:00

Variables: NSMutableDictionary *rootObj; NSDictionary *innerDict; NSString *name; NSArray *scores; Code: rootObj = [NSMutableDictionary dictionaryWithCapacity:2];

  • 0

Variables:

NSMutableDictionary *rootObj;
NSDictionary *innerDict;
NSString *name;
NSArray *scores;

Code:

rootObj = [NSMutableDictionary dictionaryWithCapacity:2];

    scores = [NSArray arrayWithObjects:[NSNumber numberWithInt:6],
              [NSNumber numberWithFloat:4.6], [NSNumber numberWithLong:6.0000034], nil];
    name = @"George Washington";



    innerDict = [NSDictionary dictionaryWithObjects:
                 [NSArray arrayWithObjects: name, scores, nil]
                                            forKeys:[NSArray arrayWithObjects:@"Name", @"Scores", nil]];
    [rootObj setObject:innerDict forKey:@"Washington"];

    scores = [NSArray arrayWithObjects:[NSNumber numberWithInt:8],
              [NSNumber numberWithFloat:4.9],
              [NSNumber numberWithLong:9.003433], nil];
    name = @"Abraham Lincoln";


    innerDict = [NSDictionary dictionaryWithObjects:
                 [NSArray arrayWithObjects: name, scores, nil]
                                            forKeys:[NSArray arrayWithObjects:@"Name", @"Scores", nil]];
    [rootObj setObject:innerDict forKey:@"Lincoln"];

    id plist = [NSPropertyListSerialization dataFromPropertyList:(id)rootObj
                                                          format:NSPropertyListXMLFormat_v1_0 errorDescription:nil];

    // SERIALIZATION

    NSString *path = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"];
    NSData *xmlData;
    NSString *error;

    xmlData = [NSPropertyListSerialization dataFromPropertyList:plist
                                                         format:NSPropertyListXMLFormat_v1_0
                                               errorDescription:&error];
    if(xmlData) {
        NSLog(@"No error creating XML data.");
        [xmlData writeToFile:path atomically:YES];
        NSFileManager *manger = [[NSFileManager alloc] init];
        NSLog(@"%@", [manger contentsAtPath:path]);
    }
    else {
        NSLog(@"error");
       // [error release];
    }

    NSMutableDictionary *myDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
    NSLog(@"%@", myDictionary);

The output is:

2013-01-18 14:33:50.066 PListTrials[11281:c07] No error creating XML data.
2013-01-18 14:33:50.067 PListTrials[11281:c07] (null)
2013-01-18 14:33:50.067 PListTrials[11281:c07] (null)

How is myDictionary null? Code pulled from: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/PropertyLists/CreatePropListProgram/CreatePropListProgram.html#//apple_ref/doc/uid/10000048i-CH5-SW1

  • 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-17T18:04:18+00:00Added an answer on June 17, 2026 at 6:04 pm

    Simple: you can’t write to the application bundle. Change path to something writeable (e. g. the Documents directory).

    Update:

    Also,

    xmlData = [NSPropertyListSerialization dataFromPropertyList:plist
                                                         format:NSPropertyListXMLFormat_v1_0
                                               errorDescription:&error];
    

    is superfluous. plist is already the XML data.

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

Sidebar

Related Questions

This is my code: (customNames and customNamesArray are static variables) -(void) loadCustomDataFromDisk { NSString
If I had an NSDictionary like this: NSMutableDictionary *valuesDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithDouble:-60.0],@a,
I have two variables in a jquery code and if item.a not exist, it
I have the following code in my class method for test: NSMutableDictionary * temp
I am having the following code: @interface Room : NSObject { @protected NSMutableDictionary* mCustomProperties;
How would I create a number of NSDictionary variables using an array's count? This
I'm using the following code to browse a NSMutableDictionary NSMutableDictionary *item; for (item in
//assign variables string measurementIn; //read in file in array string[] lines = File.ReadAllLines(../../convert.txt); //ask
Are variables declared inside a static block accessible anywhere else? What kind of member
I have these variables: boost::regex re //regular expression to use std::string stringToChange //replace this

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.