Re: You can give propertyListFromData: a C string!
Re: You can give propertyListFromData: a C string!
- Subject: Re: You can give propertyListFromData: a C string!
- From: Ed Baskerville <email@hidden>
- Date: Sat, 27 May 2006 13:37:54 -0700
I see Bill just answered, but here's a longer version...
(a) No, you're not nuts!
(b) Yes, it did! In fact, Cocoa still does this if you serialize to
that format. By definition, a property list is any object graph that
contains recursively a certain set of classes. The subset of these
that can be properly serialized and deserialized in OpenStep ASCII
format are NSString, NSDictionary, NSArray, and NSData.
For further reading, check out
http://developer.apple.com/documentation/cocoa/Conceptual/PropertyLists/
and, for a long discussion of a "bug" and the semantics of the
description method:
http://lists.apple.com/archives/cocoa-dev/2006/Mar/msg01349.html
(and the messages leading up to it).
--Ed
On May 27, 2006, at 11:24 AM, Jerry Krinock wrote:
I am trying to fix a bug in my program. The bug causes a C string
to be fed
to NSPropertyListSeralization for deserialization. The crazy thing
is, it
actually works:
char* hello = "Hello" ;
NSData* data = [[NSData alloc] initWithBytes:hello length:5] ;
NSString *plistError;
NSPropertyListFormat format;
id plist ;
plist = [NSPropertyListSerialization propertyListFromData:data
mutabilityOption:NSPropertyListImmutable
format:&format
errorDescription:&plistError];
NSLog(@"Detected plist format as: %i", format) ;
NSLog(@"Deserialized plist to get a %@: %@",
[plist class],
plist) ;
You'd think plist is going to be nil? Nope...
MyApp[2076] Detected plist format as: 1
MyApp[2076] Deserialized plist to get a NSCFString: Hello
One telltale clue is that format = 1 is defined as
kCFPropertyListOpenStepFormat, which I have never seen before.
So that I can clear my head and continue working on the REAL bug,
could
someone please confirm: (a) Am I nuts, or (b) did OpenStep
"serialize" an
NSString by simply pumping out its ASCII bytes?
Jerry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40edbaskerville.com
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