• 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: 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


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

  • Prev by Date: Re: How to Display Simplified Print Panel
  • Next by Date: Re: NSString propertyList crash
  • Previous by thread: Re: NSString propertyList crash
  • Next by thread: Re: NSString propertyList crash
  • Index(es):
    • Date
    • Thread