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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:58:00+00:00 2026-05-26T14:58:00+00:00

I’m using the following code to save a NSMutableDictionary to file then retrieve it

  • 0

I’m using the following code to save a NSMutableDictionary to file then retrieve it later.

The NSLog in the save method works fine, but the NSLog in retreive method logs null.

- (void)saveDataToFile
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"cahchedTemplates"];
    [self.workflowTemplates writeToFile:filePath atomically:TRUE];
    NSLog(@"template save: %@", self.workflowTemplates);
}

- (IBAction)retrieveDataButtonPressed:(id)sender
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"cahchedTemplates"];
    NSMutableDictionary *tempDic = [NSMutableDictionary dictionaryWithContentsOfFile:filePath]; 
    NSLog(@"tempDict: %@", tempDic);
}

+(NSMutableDictionary*)getClinicalTemplatesAndWorkFlowTemplates:(NSInteger)appointmentId
{
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/ichrono/20110715/60b88126/fetch_clinical_templates/", [self getDrChronoHost]]];

    ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
    [self addCurrentUserLoginToPostRequest:request];
    [request setPostValue:[NSString stringWithFormat:@"%d", appointmentId] forKey:@"appointment_id"];

    [request startSynchronous];
    NSError *error = [request error];
    NSString *responseString;
    if (!error) {
        responseString = [request responseString];
    } else {
        //return [[NSString alloc] initWithString:@"Failed to connect to DrChrono.com, please check your WiFi or 3G connection."];
        NSMutableDictionary *returnContainer = [[[NSMutableDictionary alloc] init] autorelease];
        [returnContainer setObject:[[[NSArray alloc] init] autorelease] forKey:@"custom_templates"];
        [returnContainer setObject:[[[NSMutableDictionary alloc] init] autorelease] forKey:@"workflow_templates"];
        return returnContainer;
    }

    NSDictionary *responseDictionary = [responseString JSONValue];
    if ((NULL == responseDictionary) || (NULL == [responseDictionary valueForKey:@"errors"])) {
        NSMutableDictionary *returnContainer = [[[NSMutableDictionary alloc] init] autorelease];
        [returnContainer setObject:[[[NSArray alloc] init] autorelease] forKey:@"custom_templates"];
        [returnContainer setObject:[[[NSMutableDictionary alloc] init] autorelease] forKey:@"workflow_templates"];
        return returnContainer;
    }

    NSMutableArray *templates = [[NSMutableArray alloc] init];
    for (id it in [responseDictionary valueForKey:@"custom_templates"]) {
        NSMutableDictionary *clinical_template = [[[NSMutableDictionary alloc] init] autorelease];

        [clinical_template setValue:[it valueForKey:@"has_data_flag"] forKey:@"has_data_flag"];

        if (0) {
            //@note: mnusimow 20101010: Activate this code to put a "*" character at beginning of templates with values.
            if (0 != [[it valueForKey:@"has_data_flag"] intValue]) {
                [clinical_template setValue:[NSString stringWithFormat:@"*%@", [it valueForKey:@"name"]] forKey:@"display"];
            } else {
                [clinical_template setValue:[it valueForKey:@"name"] forKey:@"display"];
            }
        } else {
            [clinical_template setValue:[it valueForKey:@"name"] forKey:@"display"];
        }
        [clinical_template setValue:[it valueForKey:@"id"] forKey:@"template_id"];

        [templates addObject:clinical_template];
    }

    NSMutableDictionary *returnContainer = [[[NSMutableDictionary alloc] init] autorelease];
    [returnContainer setObject:templates forKey:@"custom_templates"];
    [returnContainer setObject:[responseDictionary valueForKey:@"workflow_templates"] forKey:@"workflow_templates"];
    return returnContainer;
}

NSLog of self.workflowTemplate

2011-11-03 13:12:11.178 app[2869:1a603] sdfsafsafa:{
    "has_manual_edits_flag" = 0;
    "hp_assessment" =     {
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
        id = 77607;
    };
    "hp_cc_history_present_illness" =     {
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
        id = 77603;
    };
    "hp_med_fam_social_history" =     {
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
        id = 77604;
    };
    "hp_medications_allergies" =     {
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
        id = "<null>";
    };
    "hp_physical_exam" =     {
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
        id = 77606;
    };
    "hp_plan" =     {
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
        id = 77608;
    };
    "hp_review_of_systems" =     {
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
        id = 77605;
    };
    "soap_assessment" =     {
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
        id = 77611;
    };
    "soap_objective" =     {
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
        id = 77610;
    };
    "soap_plan" =     {
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
        id = 77612;
    };
    "soap_subjective" =     {
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
        id = 77609;
    };
}

Edit:

Updated dictionary without id object

2011-11-03 16:28:31.136 app[11158:1a603] sdfsafsafa:{
    "has_manual_edits_flag" = 0;
    "hp_assessment" =     {
        "db_id" = 77607;
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
    };
    "hp_cc_history_present_illness" =     {
        "db_id" = 77603;
        "has_data_flag" = 1;
        "has_manual_edits_flag" = 0;
    };
    "hp_med_fam_social_history" =     {
        "db_id" = 77604;
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
    };
    "hp_medications_allergies" =     {
        "db_id" = "<null>";
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
    };
    "hp_physical_exam" =     {
        "db_id" = 77606;
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
    };
    "hp_plan" =     {
        "db_id" = 77608;
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
    };
    "hp_review_of_systems" =     {
        "db_id" = 77605;
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
    };
    "soap_assessment" =     {
        "db_id" = 77611;
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
    };
    "soap_objective" =     {
        "db_id" = 77610;
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
    };
    "soap_plan" =     {
        "db_id" = 77612;
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
    };
    "soap_subjective" =     {
        "db_id" = 77609;
        "has_data_flag" = 0;
        "has_manual_edits_flag" = 0;
    };
}
  • 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-26T14:58:00+00:00Added an answer on May 26, 2026 at 2:58 pm

    The method writeToFile:atomically: returns a BOOL, which you should check. If it’s failing, then you most likely have something in your dictionary which cannot be written out. Only the basic object types can be written out from a dictionary. See my answer to this question: iPhone – Writing a dictionary to file : handling errors as well as the docs for writeToFile:atomically:.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.