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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:20:45+00:00 2026-05-24T16:20:45+00:00

I have a dictionary with nested dictionaries (as per flash cards) in my application.

  • 0

I have a dictionary with nested dictionaries (as per “flash cards”) in my application. For some reason, the NSDictionary will not write to file. If I simply call writeToFile on my dictionary, it doesn’t work, and NSPropertyListSerialization returns Property List invalid for Format. The code is as follows:

#import "flashCard.h"

#define kFront @"front"
#define kBack @"back"

@implementation flashCard

- (id) init
{
if (self = [super init])
{
    cards = [[NSDictionary alloc] initWithObjectsAndKeys:
             [[NSDictionary alloc] initWithObjectsAndKeys:
              @"aetas/aetatis", kFront,
              @"lifetime, age, generation", kBack,
              nil], [NSNumber numberWithInt: 1],
             [[NSDictionary alloc] initWithObjectsAndKeys:
              @"amicitia/amicitiae", kFront,
              @"alliance, friendship", kBack,
              nil], [NSNumber numberWithInt: 2],
             [[NSDictionary alloc] initWithObjectsAndKeys:
              @"amicus/amici", kFront,
              @"friend", kBack,
              nil], [NSNumber numberWithInt: 3],
             [[NSDictionary alloc] initWithObjectsAndKeys:
              @"animus/animi", kFront,
              @"mind, heart, spirit, courage", kBack,
              nil], [NSNumber numberWithInt: 4],
             nil];

    currentSide = [[NSString alloc] init];

    currentCard = 1;
    currentSide = kFront;
}

return self;
}

later, in the same implementation…

- (void) saveSet
{
NSLog(@"saveSet called");
NSSavePanel *cocaoSavePanel = [NSSavePanel savePanel];

int buttonPressed = [cocaoSavePanel runModal];
if (buttonPressed != NSOKButton)
{
    return;
}

NSLog(@"ok button, with url: %@", [cocaoSavePanel URL]);

NSError *error;
NSData *plistData = [NSPropertyListSerialization dataWithPropertyList:cards
                     format:NSPropertyListXMLFormat_v1_0
                                                    options: 0
                     error: &error];

if (plistData)
{
    [plistData writeToURL:[cocaoSavePanel URL] atomically:YES];
    NSLog(@"File Saved Successfully");
}
else {
    NSLog(@"%@", error);
}
}

Any help would be appreciated.

EDIT: after revisions:

2011-08-12 13:00:47.937 flashcards[14452:a0f] saveSet called
2011-08-12 13:00:48.763 flashcards[14452:a0f] ok button, with url: file://localhost/Users/sam/Desktop/asdf
2011-08-12 13:00:48.764 flashcards[14452:a0f] {
    3 =     {
        back = friend;
        front = "amicus/amici";
    };
    2 =     {
        back = "alliance, friendship";
        front = "amicitia/amicitiae";
    };
    1 =     {
        back = "lifetime, age, generation";
        front = "aetas/aetatis";
    };
    4 =     {
        back = "mind, heart, spirit, courage";
        front = "animus/animi";
    };
}
2011-08-12 13:00:48.764 flashcards[14452:a0f] Property list invalid for format: 100
Program received signal:  “EXC_BAD_ACCESS”.
sharedlibrary apply-load-rules all
  • 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-24T16:20:46+00:00Added an answer on May 24, 2026 at 4:20 pm
    currentSide = [[NSString alloc] init];
    
    currentCard = 1;
    currentSide = kFront;
    

    That leaks the empty NSString (or, would, but that [[NSString alloc] init] returns a singleton coincidentally). Also, you are leaking all of the dictionaries that you put into the outer cards dictionary.

    Generally, when this kind of error pops up, it is because you have a non-plist-compatible object in your dictionaries/arrays; something that isn’t an NSNumber, NSArray, NSDate, NSData, NSString, NSDictionary, etc….

    NSLog(@"%@", cards); right before serialization and post that. Also what is the exact plist serialization format error?


    I just copy/pasted your code and got:

    asdfasdf[81731:707] Property list invalid for format (property list dictionaries may only have keys which are CFStrings, not 'CFNumber')
    
    • you can’t have keys that are numbers

    • always read and post the entirety of the error messages spewed at runtime

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

Sidebar

Related Questions

I have the following nested dictionaries: Dictionary<int, Dictionary<string, object>> x; Dictionary<int, SortedDictionary<long, Dictionary<string, object>>>
Suppose I have a dictionary, and it's nested with dictionaries inside. I want to
I'm stumped. I have an NSMutableDictionary w/ nested dictionaries that I am enumerating through
I have a dictionary of dictionaries with the following structure: 1:{'Amendment': '1', 'status': 'Stadf\xc3\xa6stet',
I have created two dictionaries in the user defaults of my application to represent
I have a nested dictionary of type following {id_1 : [ {id_2:score},{id_3:score_2} .... and
I have a array with nested dictionary data like this: [{ link : [
I have an object that consists primarily of a very large nested dictionary: class
I have nested dictionaries: {'key0': {'attrs': {'entity': 'p', 'hash': '34nj3h43b4n3', 'id': '4130'}, u'key1': {'attrs':
Here is the situation. I have some ViewModels that contain nested complex model types.

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.