Re: NSString propertyList crash
Re: NSString propertyList crash
- Subject: Re: NSString propertyList crash
- From: Tito Ciuro <email@hidden>
- Date: Sun, 19 Mar 2006 20:39:18 -0800
Hi Andy,
That works fine. :-)
On 19/03/2006, at 20:07, Andy Lee wrote:
On Mar 19, 2006, at 10:20 PM, Andy Lee wrote:
I suspect the solution is to use whatever CoreFoundation function
is the inverse of CFPropertyListCreateFromXMLData(), because the
Objective-C APIs for doing what you want are broken right now.
I take that back. As others have suggested in this and your
previous thread, NSPropertyListSerialization is your friend:
NSString *dirPath = [[myTextField2 stringValue]
stringByExpandingTildeInPath];
NSDictionary *dict = [NSDictionary
dictionaryWithContentsOfFile: dirPath];
NSLog(@"dict: %@", dict);
NSString *err = nil;
NSData *dictData =
[NSPropertyListSerialization
dataFromPropertyList:dict
format:NSPropertyListXMLFormat_v1_0
errorDescription:&err];
NSString *dictXML =
[[[NSString alloc]
initWithBytes:(const void *)[dictData bytes]
length:[dictData length]
encoding:NSUTF8StringEncoding] autorelease];
NSLog(@"dictXML: %@", dictXML);
Just for completeness, adding the following statement will convert
the NSString to a dictionary:
NSDictionary *newDict = [dictXML propertyList];
NSLog(@"newDict: %@", newDict);
Thanks a lot everybody for your prompt answer.
Regards,
-- Tito
_______________________________________________
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