Property list supported ObjC types

放肆的年华 提交于 2020-01-06 12:37:26

问题


Is it correct to say that property list files (.plist) only handle NSString, NSNumber, NSDate and NSData (allowing to store any other type which conforms to NSCoder) + NSArray / NSDictionary of those types?


回答1:


Yep, that is pretty much the exact definition of a property list. Wikipedia has a little table that explains how each class will be stored in the resulting XML file:

Foundation class    XML Tag                  Storage format
NSString            <string>                 UTF-8 encoded string
NSNumber            <real>, <integer>        Decimal string
NSNumber            <true />, or <false />   No data (tag only)
NSDate              <date>                   ISO 8601 formatted string
NSData              <data>                   Base64 encoded data
NSArray             <array>                  Can contain any number of child elements
NSDictionary        <dict>                   Alternating <key> tags and plist element tags



回答2:


Property List can only contains following types of data:

NSString NSNumber NSNumber NSDate NSData NSArray NSDictionary

for more information visit: Property List Format or visit Apple Docs

You can also save other objects as NSData by serializing them



来源:https://stackoverflow.com/questions/13295517/property-list-supported-objc-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!