Plist is used for storage of data in iOS app. Plist save data in form of Array and Dictionaries. In plist we can save data as: 1. Static data to be used in app. 2. Data that will be coming from server.
1. Static data to be used in app.
To save static data in plist follow these methods:
a) Add a new file
b) Click Property list in Resources
c) Name the propertylist and a file will be created as(data.plist here)
d) You can create a plist of Arrays and Dictionaries as:
// Read plist from bundle and get Root Dictionary out of it
// Your dictionary contains an array of dictionary
// Now pull an Array out of it.
Save and edit/delete data from Plist
You have already created a plist. This plist will remain same in app. If you want to edit the data in this plist, add new data in plist or remove data from plist, you can't make changes in this file.
For this purpose you will have to store your plist in Document Directory. You can edit your plist saved in document directory.
Save plist in document directory as:
Retreive data from Plist as:
You can edit remove, add new data as per your requirement and save the plist again to Document Directory.
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0