Plist:它是什么以及如何使用 [英] Plist: what it is and how to use it

查看:112
本文介绍了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?

推荐答案

使用以下代码,您可以轻松地将plist的内容获取到数组中(我们在此处打开名为'file.plist'的文件Xcode项目):

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):

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"plist"];
contentArray = [NSArray arrayWithContentsOfFile:filePath];

plist只是一个XML文件,它对应于Apple设计的某些DTD(数据类型字典),可以在此处看到DTD:

A plist is just a XML file which corresponds to some DTD (datatype dictionary) designed by Apple, the DTD can be seen here:

http://www.apple.com/DTDs/PropertyList-1.0.dtd

DTD以及其他内容描述了XML文件可以包含的对象"和数据类型.

The DTD -among other things- describes the "objects" and datatypes that the XML file can contain.

这篇关于Plist:它是什么以及如何使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆