Re: NSString propertyList crash
Re: NSString propertyList crash
- Subject: Re: NSString propertyList crash
- From: Ed Baskerville <email@hidden>
- Date: Mon, 20 Mar 2006 11:57:58 -0800
On Mar 20, 2006, at 1:31 AM, Andy Lee wrote:
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.
That's almost right: they're perfect inverses for dictionaries (or
arrays) that recursively contain only valid objects for ASCII plists:
NSDictionary, NSArray, NSString, NSData. (I'm sure that's what you
meant, but it's worth clarifying for anyone reading.) Throw any other
kind of object in the graph, and although the description method
still works, if you try to parse the plist, you'll get strings where
you previously had other objects. Rather, you *should* get strings in
place of other objects, but in fact the bug that started this whole
thread means that the strings are not property wrapped in "" marks
and parsing actually fails.
But the point is that description methods, although they *can* be
used for serialization, *should not* be used in that way, as I think
everyone here now understands. We shouldn't be telling beginners that
they can serialize objects using these methods only to have them soon
discover that they can't serialize their own custom objects this way
and, furthermore, that there's another mechanism entirely that they
should be using. The docs aren't intended to lead people down this
path, but many beginners still seem to be getting the incorrect
message that description methods are for serialization. Hence the doc
bug. (Full disclosure: I should have fixed this when I was revising
the property list documentation as an intern in Apple Tech Pubs four
years ago. Sorry about not catching it then.)
--Ed
_______________________________________________
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