Introduction to Property Lists

注意: 本文档翻译于2018年01月27日。如果Apple在这之后更新了文档,可能出现翻译跟官方原文不匹配的情况。原文

Property lists organize data into named values and lists of values using several object types. These types give you the means to produce data that is meaningfully structured, transportable, storable, and accessible, but still as efficient as possible. Property lists are frequently used by applications running on both OS X and iOS. The property-list programming interfaces for Cocoa and Core Foundation allow you to convert hierarchically structured combinations of these basic types of objects to and from standard XML. You can save the XML data to disk and later use it to reconstruct the original objects.

属性列表使用几种对象类型将数据组织到命名值和值列表中。这些类型为您提供了生成有意义的结构,可传输,可存储和可访问的数据的手段,但仍尽可能地高效。 属性列表经常被在OS X和iOS上运行的应用程序使用。 Cocoa和Core Foundation的属性列表编程接口允许您将这些基本对象类型的层次结构化组合转换为标准XML,或者从标准XML转换而来。您可以将XML数据保存到磁盘,之后使用它重建原始的对象。

This document describes property lists and their various representations, and how to work with them using both certain Foundation classes of Cocoa and Property List Services of Core Foundation.

本文档介绍了属性列表及其各种表示形式,以及如何使用Cocoa的某些Foundation类和Core Foundation的属性列表服务来处理它们。

Note: The user defaults system, which you programmatically access through the NSUserDefaults class, uses property lists to store objects representing user preferences. This limitation would seem to exclude many kinds of objects, such as NSColor and NSFont objects, from the user default system. But if objects conform to the NSCoding protocol they can be archived to NSData objects, which are property list–compatible objects. For information on how to do this, see “Storing NSColor in User Defaults“; although this article focuses on NSColor objects, the procedure can be applied to any object that can be archived.

注意: 通过NSUserDefaults类以编程方式访问的默认的用户系统使用属性列表来存储表示用户首选项的对象。这个限制似乎从用户默认系统中排除了许多种类的对象,比如NSColorNSFont对象。 但是,如果对象符合NSCoding协议,则可以将其归档到属性列表兼容的NSData对象。有关如何执行此操作的信息,请参“在用户默认值中存储NSColor”; 虽然本文重点介绍NSColor对象,但该过程可以应用于任何可以归档的对象。

Organization of This Document 本文档的组织

This document consists of the following chapters:

本文档由以下章节组成: