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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:21:00+00:00 2026-05-13T22:21:00+00:00

I have one dictionary I need to save into a plist. The paletteDictionary always

  • 0

I have one dictionary I need to save into a plist. The paletteDictionary always returns nil:

- (void)saveUserPalette:(id) sender
{
    [paletteDictionary setObject:matchedPaletteColor1Array forKey:@"1"];

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"UserPaletteData.plist"];
    // write plist to disk
    [paletteDictionary writeToFile:path atomically:YES];    
}

I’m reading the data back in a different view like:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"UserPaletteData.plist"];

NSMutableDictionary *plistDictionary = [NSMutableDictionary dictionaryWithContentsOfFile:path];
if(plistDictionary==nil ){
    NSLog(@"failed to retrieve dictionary from disk");
}
  • 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-13T22:21:00+00:00Added an answer on May 13, 2026 at 10:21 pm

    Run your application in the simulator and browse to the following path:

    ~/Library/Application Support/iPhone Simulator/User/Applications/{A GUID}/Documents

    Where A GUID will be a string like this: 06430A38-AFAC-4C68-8F39-DBD6C81A5AA6 (it’s probably the Last Modified folder).

    Verify that UserPaletteData.plist is present and load it up in Property List Editor.app to verify that it contains some data.

    Also make sure that the you use only the following data types in your dictionary otherwise it will fail to write to a plist: (NSData, NSDate, NSNumber, NSString, NSArray, or NSDictionary).

    To verify that the dictionary you are attempting to save to disk is valid for a plist, try the following:

    for (id key in paletteDictionary) 
    {
        NSLog(@"key: %@, value: %@, class: %@", key, [paletteDictionary objectForKey:key], NSStringFromClass([[paletteDictionary objectForKey:key] class]));
    }
    

    That should tell you if any of your objects are the wrong data type for a plist.

    If that is still not helping, then you should make sure that paletteDictionary has been alloc/init’ed before saveUserPalette is called.

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

Sidebar

Related Questions

I need to save 2 values in one list so I have all the
I have simple task where I need to check objects in one dictionary and
I have a function written in C# which has one parameter type as Dictionary<string
I have an object Dictionary<int, Dictionary<int, Foo> > on one side, and a function
I have a dictionary of struct, where one member is a list containing varying
I have a form with one textbox and one button. Here I need to
So I have a Python assignment where I need to use a dictionary to
I'm new to plists, and I really need to use one. What I have
The problem: I have Dictionary<String, String> that I need an alias to, but I
I have a Dictionary with a few hundred thousand elements. I need to perform

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.