Property List 支持的数据类型(us…
2014-01-23 17:27
399 查看
Property list
Prerequisite Articles
Objectgraph
Collection
Related Articles
ArchivingObject
mutability
A property list is a representation of a hierarchy of objects that
can be stored in the file system and reconstituted later. Property
lists give applications a lightweight and portable way to store
small amounts of data. They are hierarchies of data made from
specific types of objects—they are, in effect, an object graph.
Property lists are easy to create programmatically and are even
easier to serialize into a representation that is persistent.
Applications can later read the static representation back into
memory and recreate the original hierarchy of objects. Both Cocoa
Foundation and Core Foundation have APIs related to property list
serialization and deserialization.
Property List Types and Objects
Property lists consist only of certain types of data: dictionaries,arrays, strings, numbers (integer and float), dates, binary data,
and Boolean values. Dictionaries and arrays are special types
because they are collections; they can contain one or multiple data
types, including other dictionaries and arrays. This hierarchical
nesting of objects creates a graph of objects. The abstract data
types have corresponding Foundation classes, Core Foundation types,
and XML elements for collection objects and value objects, as shown
in the following list:
Abstract type | Foundation framework class | Core Foundation type | XML element |
---|---|---|---|
Array | NSArray | CFArrayRef | <array> |
Dictionary | NSDictionary | CFDictionaryRef | <dict> |
String | NSString | CFStringRef | <string> |
Data | NSData | CFDataRef | <data> |
Date | NSDate | CFDateRef | <date> |
Integer | NSNumber( intValue32-bit) NSNumber( integerValue64-bit) | CFNumberRef( kCFNumberSInt32Type) CFNumberRef( kCFNumberSInt64Type) | <integer> |
Floating-point value | NSNumber( floatValue32-bit) NSNumber( doubleValue64-bit) | CFNumberRef( kCFNumberFloat32Type) CFNumberRef( kCFNumberFloat64Type) | <real> |
Boolean | NSNumber( boolValue) | CFBooleanRef | <true/>or <false/> |
Mutable versions of the Foundation classes are also supported. |
as property
list objects. For example, an
NSMutableDictionaryobject
is a property list object, as are
NSNumberobject,
an
NSStringobject,
and so on. For a property list to be valid, all objects in the
object graph must be property list objects.
Best Practices for Property Lists
You can write property lists out in both XML and binary formats.The binary format is much more compact than the XML version and
thus more efficient. It is recommended for most situations.
However, you can manually edit an XML property list if you ever
need to. Property list files have the filename extension
of
plist.
You should not use property lists to store large, complex graphs of
objects, especially when the objects have variable mutability
settings. And you cannot use property lists to store objects that
are not supported by the architecture, such as model objects. For
these cases, use archiving instead. Although property lists can
include
NSDataobjects,
it’s best to not use data objects in property lists to hold large
amounts of binary data.
Property List Serialization
To serialize and deserialize property lists, call the appropriateclass methods of the
NSPropertyListSerializationclass
or, if using Core Foundation, the facilities related to
the
CFPropertyListRefopaque
type. In Cocoa, the serialized output is in the form of
an
NSDataobject.
You can therefore use the methods of that class (for
example,
writeToFile:atomically:)
to write that data to the file system and use the
appropriate
NSDataclass
factory memory to read it back into memory. Then, when you
deserialize it, you can specify mutability options for the property
list.
Definitive Discussion
Property ListProgramming Guide
Sample Code Projects
People© 2012 Apple Inc. All Rights Reserved. (Last updated:
2012-02-16)
Did this document help you? Yes It's good,
but... Not
helpful...
相关文章推荐
- 关于interval to......数据类型
- java List Collections.sort 排序 支持 对象属性 普通数据类型 升序 降序 正序 倒序 排列
- PHP 布尔数据类型
- 数据类型所佔用内存大小 (200…
- 让QT 4.7 支持DBUS调用中传递"aas(字符串二维数组)“ 数据据类型
- Python 1、数据类型&List&Tuple&Dict&Set
- Android中将List<Map<String, Object>>类型数据与字符串的相互转化
- 常用数据类型转换CString do…
- java List Collections.sort 排序 支持 对象属性 普通数据类型
- 判断数据类型 python
- Oracle&nbsp;date类型数据
- Python3学习(一)-基础、数据类型、变量、字符串和编码、list&tuple、if、for、while、dict、set、函数与参数
- JavaScript 数据类型
- String是最基本的数据类型吗?&nbsp…
- oracle的使用<一>支持的数据类型
- Vbscript&nbsp;数据类型转化函数总结
- SQL Server 2005 不支持"date"数据类型的解决办法
- SQL 数据类型
- C++&nbsp;数据类型转换(static_ca…
- 【原创】C++链表如何像Python List一样支持多种数据类型