embedding a dictionary in a dictionary.
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.