• 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
Re: Writing nested dictionary fails
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing nested dictionary fails


  • Subject: Re: Writing nested dictionary fails
  • From: Mike Ferris <email@hidden>
  • Date: Mon, 16 Dec 2002 17:01:16 -0800

The font attributes are presumably going to include an NSFont object... NSFont is not a plist-able object. NSDictionary's writeToFile:atomically: writes property lists only, it is not a general archiving mechanism. And the attributes used by NSTextStorage are often not plist objects.

One possible solution for you would be to archive the attribute dictionary (the standard Cocoa attribute values all conform to NSCoding). Then you can put the resulting NSData in your dictionary. Sketch actually does this for the whole NSTextStorage objects that it uses in its TextArea object to store the contents if you want an example...

Mike Ferris


Begin forwarded message:

From: Thomas Harrington <email@hidden>
Date: Mon Dec 16, 2002 4:38:21 PM US/Pacific
To: email@hidden
Subject: Writing nested dictionary fails

I have a situation where an NSDictionary which contains another NSDictionary fails to writeToFile:atomically, though the file destination is valid. Basically this:

NSAttributedString *str; // Initialized elsewhere
NSDictionary *foo = [str fontAttributesInRange:NSMakeRange(0,0)];

NSMutableDictionary *bar = [NSMutableDictionary dictionary];
[bar setObject:foo forKey:@"dictKey"];
[bar setObject:@"tph" forKey:@"user"];

[bar writeToFile:@"/tmp/test" atomically:YES];

The writeToFile fails. But if I comment out the line that adds the nested dictionary, writeToFile succeeds. Why can't I write this nested dictionary to a file? Printing out its description works fine, so I know the structure's as I expect it, but I can't get it on disk.

--
Tom Harrington
email@hidden
_______________________________________________
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.
_______________________________________________
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: Writing nested dictionary fails
      • From: Thomas Harrington <email@hidden>
References: 
 >Writing nested dictionary fails (From: Thomas Harrington <email@hidden>)

  • Prev by Date: Re: NSTextView headers and footers?
  • Next by Date: Size limit for NSData.
  • Previous by thread: Writing nested dictionary fails
  • Next by thread: Re: Writing nested dictionary fails
  • Index(es):
    • Date
    • Thread