博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Property List 支持的数据类型(us…
阅读量:4072 次
发布时间:2019-05-25

本文共 3509 字,大约阅读时间需要 11 分钟。

Property list

Prerequisite Articles

  • Object graph
  • Collection

Related Articles

  • Archiving
  • Object 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

<array>

Dictionary

<dict>

String

<string>

Data

<data>

Date

<date>

Integer

 ( 32-bit)

NSNumber (64-bit)

()

()

<integer>

Floating-point value

NSNumber (32-bit)

NSNumber (64-bit)

()

()

<real>

Boolean

NSNumber ()

<true/> or<false/>

Mutable versions of the Foundation classes are also supported.

Collectively, instances of these classes are known as property list objects. For example, anNSMutableDictionary object is a property list object, as are NSNumber object, an NSString object, 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 ofplist.

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 NSData objects, 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 appropriate class methods of the class or, if using Core Foundation, the facilities related to the opaque type. In Cocoa, the serialized output is in the form of an NSData object. You can therefore use the methods of that class (for example, ) to write that data to the file system and use the appropriate NSData class factory memory to read it back into memory. Then, when you deserialize it, you can specify mutability options for the property list.

Definitive Discussion

Sample Code Projects

  • People

© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-02-16)

Did this document help you? 
 
 

转载地址:http://sjeji.baihongyu.com/

你可能感兴趣的文章
自定义切面会吃掉异常,导致事务不生效的问题。
查看>>
我们发送一个请求时,服务端的javax.servlet.http.HttpServletRequest帮我们做了什么?
查看>>
一、实现多线程的三种方式
查看>>
新手报到第一天
查看>>
折半查找法
查看>>
VirtualBox安装Centos6.4不能为虚拟电脑打开一个新的任务
查看>>
Virtual 下安装CentOs6.4
查看>>
CentOS下配置软RAID
查看>>
GET http://test01.com/jquery-1.9.1.min.js [HTTP/1.1 404 Not Found 3ms]
查看>>
echo(),print(),print_r()之间的区别?
查看>>
jQuery中$('#selector).html('')是清空??----html()、text()、val()的区别
查看>>
欢迎使用CSDN-markdown编辑器
查看>>
Python使用web.py读取Mysql的数据
查看>>
web.py操作mysql的数据
查看>>
python类的详析
查看>>
web.py的两种更新Mysql数据的方法
查看>>
前端网址总结
查看>>
前端知识总结一
查看>>
Python 字符串的操作
查看>>
python安装依赖modules pysnmp pyasn1.type pexpect configparser
查看>>