discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML-style plists with the [NSDictionary writeToFile:]


From: hns
Subject: Re: XML-style plists with the [NSDictionary writeToFile:]
Date: Tue, 28 Apr 2009 12:40:52 -0700 (PDT)
User-agent: G2/1.0

On 28 Apr., 19:33, Torli Birnbauer <goot...@gmail.com> wrote:
> Валерий, what did you expect to get. The output is dictionary style
> set of key/value pairs. There is no mistake here, or am I missing
> something?
>
> On Tue, 2009-04-28 at 17:07 +0400, Мелешкин Валерий wrote:
> > To my surprise, just after execution of app "opts.out.plist" looks like 
> > this:
>
> >    {
> >            Name = "John Doe";
> >            Phones = (
> >            "408-974-0000",
> >            "503-333-5555"
> >            );
> >    }
>
> > Where a mistake is?
>
> > _______________________________________________
> > Discuss-gnustep mailing list
> > Discuss-gnus...@gnu.org
> >http://lists.gnu.org/mailman/listinfo/discuss-gnustep

AFAIK, [dict writeToFile: @"./opts.out.plist" atomically: YES]; writes
always in NSPropertyListOpenStepFormat while
dictionaryWithContentsOfFile: tries all formats it knows. So you have
written a plist format converter.

To force writing of XML, use: NSPropertyListSerialization to convert
the NSDictionary into XML and then, writeToFile: the NSData result.

=>

[[NSProperyListSerialization dataFromPropertyList:dict
format:NSPropertyListXMLFormat_v1_0 errorDescription:&err]
writeToFile: @"./opts.out.plist" atomically: YES];

-- hns



reply via email to

[Prev in Thread] Current Thread [Next in Thread]