Re: Using NSPropertyListSerialization with NSArray of NSDictionaries
Re: Using NSPropertyListSerialization with NSArray of NSDictionaries
- Subject: Re: Using NSPropertyListSerialization with NSArray of NSDictionaries
- From: Rick Hoge <email@hidden>
- Date: Wed, 4 May 2005 11:57:45 -0400
Ok I found my inevitable dumb mistake in this - could be helpful to
someone out there...
The dictionaries I was trying to serialize used to include the return
value of [myDocument fileName] to record some provenance
information. After seeing that fileName is slated for deprecation in
favor of fileURL under the Tiger docs, I dutifully changed fileName
to fileURL in a number of places. The problem is that, while
fileName returns an NSString (which can be serialized), fileURL
returns an NSURL (which can't). Changing things to get rid of the
NSURL in the dictionary solved the problem.
Rick
On May 2, 2005, at 4:25 PM, Rick Hoge wrote:
It would be very useful for us to store an ordered array of
dictionaries using NSPropertyListSerialization. The code below
works fine if processingInfo is an NSDictionary, but fails with the
message "Property list invalid for format" if processingInfo is an
array of dictionaries.
Is there any other reasonable way to do this? The docs say that as
long is everything is an array, dictionary, number, string, or date
it should work. Should I file a bug?
Thanks for any hints,
Rick
if (processingInfo) {
xmlData = [NSPropertyListSerialization dataFromPropertyList:
[processingInfo objectAtIndex:0]
format:NSPropertyListXMLFormat_v1_0
errorDescription:&error];
if (xmlData) {
char *str = malloc([xmlData length]+1); // Add trailing '\0'
memcpy(str,[xmlData bytes],[xmlData length]);
str[[xmlData length]] = '\0';
miattputstr(mincid, varid, "processingInfo", str);
free(str);
} else {
NSLog(error);
[error release];
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40nmr.mgh.harvard.edu
This email sent to email@hidden
_______________________________________________
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