• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSString propertyList crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString propertyList crash


  • Subject: Re: NSString propertyList crash
  • From: Andy Lee <email@hidden>
  • Date: Sun, 19 Mar 2006 23:07:30 -0500

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);


You now have an NSString containing XML, and an NSData that you can use to reconstitute the original dictionary using NSPropertyListSerialization.


--Andy

_______________________________________________
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


  • Follow-Ups:
    • Re: NSString propertyList crash
      • From: Tito Ciuro <email@hidden>
References: 
 >NSString propertyList crash (From: Tito Ciuro <email@hidden>)
 >Re: NSString propertyList crash (From: Andy Lee <email@hidden>)

  • Prev by Date: Re: NSString propertyList crash
  • Next by Date: Socket detecting disconnect?
  • Previous by thread: Re: NSString propertyList crash
  • Next by thread: Re: NSString propertyList crash
  • Index(es):
    • Date
    • Thread