Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
149 views
in Technique[技术] by (71.8m points)

ios - Steps to create and edit a plist file in Xcode

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

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

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

enter image description here

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

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

enter image description here

Right click in the file and choose "Add Row"

enter image description here

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

enter image description here

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

enter image description here

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:

enter image description here

Edit the values to the three items that you want

enter image description here

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.

enter image description here

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

enter image description here

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"

enter image description here

And you'll see the raw file

enter image description here

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

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...