• 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: NSString propertyList crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString propertyList crash


  • Subject: Re: NSString propertyList crash
  • From: Andy Lee <email@hidden>
  • Date: Mon, 20 Mar 2006 04:31:06 -0500

On Mar 20, 2006, at 1:07 AM, Greg Herlihy wrote:
NSDictionary's description and propertyList methods are not perfect inverse
operations - specifically all NSDate values in the original dictionary
become NSString values when the dictionary is reconstituted from the
description string.

The documentation for the two methods strongly implies -description and -propertyList *are* perfect inverses when you're dealing with dictionaries. I suspect they actually are perfect inverses if you stick to NSPropertyListOpenStepFormat, and I suspect the documentation simply hasn't been updated since that was the standard plist format.


If I understand correctly from all this, there are three levels of plist support:

* -descriptionInStringsFileFormat and - propertyListFromStringsFileFormat. This level only supports flat dictionaries of strings (duh), which is why I shouldn't have been surprised that a date didn't work.

* -description and -propertyList. This level supports the old OpenStep format (without date support) in both directions. - propertyList has been updated to parse XML as well as OpenStep format, but -description still generates OpenStep format, on the theory that you should be conservative in the outputs you generate but liberal in the inputs you accept.

* NSPropertyListSerialization, which handles all formats (NSPropertyListOpenStepFormat, NSPropertyListXMLFormat_v1_0, and NSPropertyListBinaryFormat_v1_0). As you say, this is what we should use now.

This kind of information loss should not be unexpected, however, because a
"description" of an object is not a serialization or an archive of that
object (but merely its string representation). In other words, there is no
guarantee that an object's description can ever be used to recreate the
object it describes exactly (it may or may not).

In general, yes, but the documentation implies -description *is* a perfect serialization in the case of NSDictionary and NSArray. For these classes, the output of -description is "formatted as a property list." The word "formatted" implies that it uses a computer- parseable syntax.


I personally wouldn't have modified the semantics of -description in this way, mainly because the -description method has a special role in the Foundation library, like the toString() method in Java. I suspect NSPropertyListSerialization is a way of rectifying this design decision.

--Andy

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSString propertyList crash
      • From: Ed Baskerville <email@hidden>
References: 
 >Re: NSString propertyList crash (From: Greg Herlihy <email@hidden>)

  • Prev by Date: Re: NSString propertyList crash
  • Next by Date: Re: String diff?
  • Previous by thread: Re: NSString propertyList crash
  • Next by thread: Re: NSString propertyList crash
  • Index(es):
    • Date
    • Thread