NSPropertyListSerialization woes
NSPropertyListSerialization woes
- Subject: NSPropertyListSerialization woes
- From: Brian Webster <email@hidden>
- Date: Sun, 20 Apr 2003 13:58:06 -0500
I have a program in which I would like to be able to write out a
property list to a file in any of the three formats, binary, ASCII, or
XML. I'm using +[NSPropertyListSerialization
dataFromPropertyList:format:errorDescription:] to get the data, and it
works fine for the XML and binary formats, but it seems to be choking
on the ASCII format for some reason. The code's pretty straightforward:
- (NSData *)dataRepresentationOfType:(NSString *)aType
{
NSString* errorString = nil;
NSData* data = [NSPropertyListSerialization
dataFromPropertyList:[self plist] format:[self plistFormat]
errorDescription:&errorString];
if (errorString != nil)
{
NSLog(@"errorString = %@", errorString);
}
NSLog(@"data = %@", data);
return data;
}
When [self plistFormat] is NSPropertyListBinaryFormat_v1_0 or
NSPropertyListXMLFormat_v1_0, it works fine, but if I use
NSPropertyListOpenStepFormat, I get a nil data object back. The
strange thing is that nothing gets returned into the errorString
argument when this happens, so I have no indication of what might be
going wrong inside. I thought it might be some issue with high ASCII
characters or something in the plist, but it exhibits the same behavior
no matter what the contents of the plist are. It can be an empty
dictionary I'm trying to write out and I get the same result.
Has anyone run across this before? Is it just a bug, or is there some
way I can work around it? PropertyListEditor seems to be able to write
ASCII plists just fine, so it must be possible (somehow).
--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.