1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"949.43">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Courier
; min-height: 12.0px}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #ad140d}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #001bb9}
19 span
.s1
{color: #0021e7}
20 span
.s2
{color: #001bb9}
21 span
.s3
{text-decoration: underline
; color: #0021e7}
22 span
.s4
{color: #000000}
23 span
.s5
{color: #2c7014}
24 span
.s6
{color: #606060}
25 span
.Apple-tab-span
{white-space:pre
}
29 <p class=
"p1"><b>writeAsPlist
</b></p>
30 <p class=
"p2"><br></p>
31 <p class=
"p3"><span class=
"s1"><a href=
"../Core/Object.html"><b>Object
</b></a></span><b> method
</b></p>
32 <p class=
"p2"><br></p>
33 <p class=
"p4">object.writeAsPlist(path);
</p>
34 <p class=
"p2"><br></p>
35 <p class=
"p3">Write the object to disk as a PropertyList.
<span class=
"Apple-converted-space"> </span>It is used commonly in OS X to store data.
<span class=
"Apple-converted-space"> </span></p>
36 <p class=
"p2"><br></p>
37 <p class=
"p3">This is an XML format that may be read from easily from Objective-C, Java or any language that uses the CoreFoundation(Cocoa) framework.
<span class=
"Apple-converted-space"> </span></p>
38 <p class=
"p2"><br></p>
39 <p class=
"p3">Objective-C:
</p>
40 <p class=
"p2"><br></p>
41 <p class=
"p4">id rootObject = [
<span class=
"s2">NSKeyedUnarchiver
</span><span class=
"Apple-converted-space"> </span>unarchiveObjectWithFile: path ];
</p>
42 <p class=
"p2"><br></p>
43 <p class=
"p3">The file may be double-clicked to open it in Property List Editor.
</p>
44 <p class=
"p2"><br></p>
45 <p class=
"p3">See also:
<a href=
"../Collections/Archive.html"><span class=
"s2">Archive
</span></a></p>
46 <p class=
"p2"><br></p>
47 <p class=
"p5"><i><span class=
"Apple-converted-space"> </span></i></p>
48 <p class=
"p3">When opening the PropertyList:
</p>
49 <p class=
"p2"><br></p>
50 <p class=
"p3">your SC objects are converted to Foundation objects in this fashion:
</p>
51 <p class=
"p2"><br></p>
52 <p class=
"p3"><span class=
"s3"><a href=
"../Math/SimpleNumber.html">SimpleNumber
</a></span> -
> NSNumber.
</p>
53 <p class=
"p3"><span class=
"s3"><a href=
"../Collections/SequenceableCollection.html">SequenceableCollection
</a></span> -
> NSArray with each item converted
</p>
54 <p class=
"p3"><span class=
"s3"><a href=
"../Collections/String.html">String
</a></span> -
> NSString
</p>
55 <p class=
"p3"><span class=
"s3"><a href=
"../Core/Symbol.html">Symbol
</a></span> -
> NSString
</p>
56 <p class=
"p3"><span class=
"s3"><a href=
"../Core/Char.html">Char
</a></span> -
> NSString
</p>
57 <p class=
"p3"><span class=
"s3"><a href=
"../Core/Nil.html">Nil
</a></span> -
> NSNull
</p>
58 <p class=
"p3"><span class=
"s3"><a href=
"../Core/Boolean.html">Boolean
</a></span> -
>NSNumber (numberWithBool:) equivalent to a CFBoolean
</p>
59 <p class=
"p3"><span class=
"s3"><a href=
"../Collections/Dictionary.html">Dictionary
</a></span> -
>NSDictionary (each item converted)
</p>
60 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
61 <p class=
"p3">Other objects
<span class=
"Apple-converted-space"> </span>-
> NSNull
</p>
62 <p class=
"p2"><br></p>
63 <p class=
"p3">Most commonly the root object is an NSDictionary or NSArray.
</p>
64 <p class=
"p2"><br></p>
65 <p class=
"p2"><br></p>
66 <p class=
"p6"><span class=
"s4">4.0.writeAsPlist(
</span>"testWritePlist.plist"<span class=
"s4">);
</span></p>
67 <p class=
"p7"><br></p>
68 <p class=
"p6"><span class=
"s4">4.writeAsPlist(
</span>"testWritePlist.plist"<span class=
"s4">);
</span></p>
69 <p class=
"p7"><br></p>
70 <p class=
"p6">"string"<span class=
"s4">.writeAsPlist(
</span>"testWritePlist.plist"<span class=
"s4">);
</span></p>
71 <p class=
"p7"><br></p>
72 <p class=
"p6"><span class=
"s5">'symbol'
</span><span class=
"s4">.writeAsPlist(
</span>"testWritePlist.plist"<span class=
"s4">);
</span></p>
73 <p class=
"p7"><br></p>
74 <p class=
"p6"><span class=
"s4">$c.writeAsPlist(
</span>"testWritePlist.plist"<span class=
"s4">);
</span></p>
75 <p class=
"p7"><br></p>
76 <p class=
"p6"><span class=
"s2">nil
</span><span class=
"s4">.writeAsPlist(
</span>"testWritePlist.plist"<span class=
"s4">);
</span></p>
77 <p class=
"p7"><br></p>
78 <p class=
"p6"><span class=
"s2">true
</span><span class=
"s4">.writeAsPlist(
</span>"testWritePlist.plist"<span class=
"s4">);
</span></p>
79 <p class=
"p7"><br></p>
80 <p class=
"p6"><span class=
"s2">false
</span><span class=
"s4">.writeAsPlist(
</span>"testWritePlist.plist"<span class=
"s4">);
</span></p>
81 <p class=
"p7"><br></p>
82 <p class=
"p6"><span class=
"s4">[
1,
</span><span class=
"s2">false
</span><span class=
"s4">,
</span><span class=
"s5">'symbol'
</span><span class=
"s4">].writeAsPlist(
</span>"testWritePlist.plist"<span class=
"s4">);
</span></p>
83 <p class=
"p7"><br></p>
84 <p class=
"p4">List[
1,false,\symbol].writeAsPlist(
"<span class="s6
">testWritePlist.plist"</span>);
</p>
85 <p class=
"p7"><br></p>
86 <p class=
"p8">// cannot convert these objects
</p>
87 <p class=
"p4">[
<span class=
"s2">Ref
</span>(pi),
<span class=
"s2">Pbind
</span>.new].writeAsPlist(
<span class=
"s6">"testWritePlist.plist"</span>);
</p>
88 <p class=
"p7"><br></p>
89 <p class=
"p9">Dictionary
<span class=
"s4">[
</span></p>
90 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"s5">\a
</span> -
> <span class=
"s6">"a"</span>,
</p>
91 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"s6">"b"</span> -
> <span class=
"s5">\b
</span>,
</p>
92 <p class=
"p4"><span class=
"Apple-tab-span"> </span>3 -
> 3.0</p>
93 <p class=
"p6"><span class=
"s4"><span class=
"Apple-tab-span"> </span>].writeAsPlist(
</span>"testWritePlist.plist"<span class=
"s4">);
</span></p>
94 <p class=
"p7"><br></p>
95 <p class=
"p7"><br></p>
96 <p class=
"p9">IdentityDictionary
<span class=
"s4">[
</span></p>
97 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"s5">\a
</span> -
> <span class=
"s6">"a"</span>,
</p>
98 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"s6">"b"</span> -
> <span class=
"s5">\b
</span>,
</p>
99 <p class=
"p4"><span class=
"Apple-tab-span"> </span>3 -
> 3.0</p>
100 <p class=
"p6"><span class=
"s4"><span class=
"Apple-tab-span"> </span>].writeAsPlist(
</span>"testWritePlist.plist"<span class=
"s4">);
</span></p>
101 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
102 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>