在Xcode中创建和编辑plist文件的步骤 [英] Steps to create and edit a plist file in Xcode

查看:1962
本文介绍了在Xcode中创建和编辑plist文件的步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 plist 中添加密钥对值。我不知道如何在XCode中添加.plist文件。我想在.plist文件中添加这些详细信息,名为 Mobile.plist

I want to add key pair values in plist. I dont know how to add the .plist file in XCode. Simply i want to add these details in .plist file named as "Mobile.plist".

Apple - iPhone,iPod,iPad
Samsung - Galaxy Y, Galaxy R, Galaxy Z
Nokia - Lumina
LG - Lg1 ,Lg2, Lg3

我已尝试使用此链接创建新的Mobile.plist文件,

I have tried the steps to create a new Mobile.plist file by using this link,

http:// iphoneincubator。 COM /博客/教程/如何到创建-AN-iphone-喜好文件。但是,我无法准确地得到它。当我尝试使用此链接中的步骤时,plist文件始终为空。我不知道如何在plist中添加键值。

http://iphoneincubator.com/blog/tutorial/how-to-create-an-iphone-preferences-file. But, i cant get it exactly. When i tried to use the steps from this link, the plist file always empty. I don't know how to add the key, values in plist.

我创建了一个名为设置的组,并添加名为Root.plist 的新plist文件。您能否提供创建.plist文件并在其中添加键值的步骤。在此先感谢。

I have created one group named as Settings and add new plist file named as Root.plist. Can you please provide the steps to create .plist file and add key,values in it. Thanks in advance.

推荐答案

右键单击要添加到的文件夹,然后选择新文件...

Right click on the folder you want to add it to and choose "New file…"

从对话框 - 创建属性列表类型的新资源文件:

From the Dialog - create a new Resource file of type Property List:

给它任意名称,将添加plist扩展名您。在这种情况下,我创建了Root.plist

Give it whatever name you want, the plist extension will be added for you. In this case I've created Root.plist

这将显示一个空白文件,其中包含Key,Type和Value列。

This will bring up a blank file with columns for Key, Type and Value.

右键单击文件并选择添加行

Right click in the file and choose "Add Row"

选择任何提供的选项,无论如何都会覆盖它。

Choose any of the presented options, you'll be overwriting it anyway.

现在更改苹果的关键。右键单击类型部分,它当前显示String并将其更改为Array。

Now change the Key to "Apple". Right click in the type section, where it currently says String and change it to Array.

点击Apple旁边的显示三角形,使其朝下,然后右键单击该行并选择添加行这将在Apple键下创建一个子行。重复此操作,直到您有三行:

Click on the disclosure triangle next to where it says Apple so it faces downwards and then right click in the row and choose "Add Row" This will create a subrow under the Apple key. Repeat this until you have three rows:

编辑你想要的三个项目的值

Edit the values to the three items that you want

点击Apple左侧的Disclosure三角形在顶行,所以它指向右边。右键单击该行并选择添加行。这将创建一个新的顶级项目。

Click on the Disclosure triangle to the left of "Apple" on the top row so it points to the right. Right click on the row and choose "Add Row". This will create a new top level item.

由于你有四个顶级项目,每个项目包含一个数组,重复上面的过程,以便你得到你想要的结构。

Since you have four top level items, each which contains an array, repeat the above process so that you get the structure you want.

如果要查看原始plist文件,请右键单击项目导航器中的plist文件,然后选择Open As | Source Code

If you want to see the raw plist file, right click on the plist file in the project navigator and choose "Open As | Source Code"

你会看到原始文件

然后返回编辑器视图:再次右键单击该文件并选择打开为|属性列表

And to get back to the editor view: right click on the file again and choose "Open As | Property List"

这篇关于在Xcode中创建和编辑plist文件的步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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