Plist:它是什么以及如何使用它
.plist 文件到底是什么以及如何使用它?当我在 xcode 中查看此内容时,它似乎生成了某种模板,而不是向我显示一些 xml 代码。有没有一种方法可以通过将内容推入数组来提取 plist 文件中的数据?另外,在哪里可以查看.plist的源代码?
What exactly is a .plist file and how would I use it? When I view this in xcode, it seems to generate some kind of template vs showing me some xml code. Is there a way that I can extract the data in a plist file by pushing the contents into an array? Also, where can I view the source of the .plist?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用以下代码轻松地将 plist 的内容放入数组中(我们在这里打开名为“file.plist”的文件,它是 Xcode 项目的一部分):
plist 只是一个 XML 文件,它对应于某些DTD(数据类型字典)由Apple设计,DTD可以在这里看到:
DTD - 除其他外things- 描述 XML 文件可以包含的“对象”和数据类型。
You can easily get the contents of a plist into an array by using the following code (we're opening here the file called 'file.plist' that's part of the Xcode project):
A plist is just a XML file which corresponds to some DTD (datatype dictionary) designed by Apple, the DTD can be seen here:
The DTD -among other things- describes the "objects" and datatypes that the XML file can contain.
Plist 是属性列表的缩写。它只是苹果用来存储数据的一种文件类型。
您可以在此处获取更多信息:
http://developer. apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man5/plist.5.html
如果您想在 plist 中阅读,请检查此处:
plist
可以是任何plist 中的顶级容器是。例如,如果 plist 是字典,那么plist
将是NSDictionary
。如果 plist 是一个数组,它将是一个NSArray
这里是格式枚举:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/PropertyLists/SerializePlist/SerializePlist.html.html
Plist is short for property list. It is just a filetype used by Apple to store data.
You can get more info here:
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man5/plist.5.html
If you want to read in plists check here:
plist
could be whatever the top level container in the plist was. For example, if the plist was a dictionary thenplist
would be anNSDictionary
. If the plist was an array it would be anNSArray
Here the format enum:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/PropertyLists/SerializePlist/SerializePlist.html.html
有关 2021 年 2 月的 @AdamH 的回答的更多信息
propertyListFromData
已被弃用 自 iOS 8.0 macOS 10.10dataWithPropertyList
Apple 似乎不正确。它应该是
propertyListWithData
而不是dataWithPropertyList
,将设备的网络配置设置转储到 stdout
A little more on @AdamH's answer from Feb. 2021
propertyListFromData
has been deprecated bysince iOS 8.0 macOS 10.10dataWithPropertyList
Apple seems to be incorrect. It should be
propertyListWithData
instead ofdataWithPropertyList
E.g. to dump device's network configuration settings to stdout