• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
embedding a dictionary in a dictionary.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

embedding a dictionary in a dictionary.


  • Subject: embedding a dictionary in a dictionary.
  • From: Jason Alexander <email@hidden>
  • Date: Mon, 28 Apr 2003 23:49:37 +0100

I'm trying to implement a save function that saves a list of entities which are (effectively) represented by a dictionary for each entry. I thought the natural way of doing this was (a) constructing a dictionary for each entry and then (b) saving a dictionary containing the dictionary for each entry. Specifically, the code consists of the following snippet:

NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity: i];
int j;
for (j=0; j<i; j++) {
NSMutableData *thisDict = [NSMutableDictionary dictionaryWithCapacity: 3];

[thisDict setObject: [NSNumber numberWithInt: [imageCell inputType]]
forKey: @"input type"];
[thisDict setObject: [NSNumber numberWithFloat: [imageCell pointSize]]
forKey: @"point size"];
[thisDict setObject: [NSString stringWithFormat: @"image-%d.pdf", j]
forKey: @"filename"];

[dict setObject: thisDict
forKey: [NSString stringWithFormat: @"%d", j]];
}

[data writeToFile: @"/tmp/foo.dict" atomically: YES];

but, when running this snippet of code, I find that the file "foo.dict" is *not* created inside /tmp, even when
/tmp/foo.dict doesn't exist beforehand. Can dictionaries not be nested in this way? If so, is there a "canonical" solution for this type of problem?

Thanks,

Jason
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: embedding a dictionary in a dictionary.
      • From: j o a r <email@hidden>
  • Prev by Date: Re: Protocols on the fly?
  • Next by Date: Re: embedding a dictionary in a dictionary.
  • Previous by thread: Re: Newbie: basic array questions
  • Next by thread: Re: embedding a dictionary in a dictionary.
  • Index(es):
    • Date
    • Thread