Hi
Property List or plist files provide a convenient way to store and access our data. Data can be stored in the form of array as well as Dictionary. It supports various primitive types such as boolean, data, date, number, and string.
We add list of item in Plist file so that it can be easily fetched, managed and displayed in our application.
To fetch array of item from plist add the following code:
var myMenuArray: NSArray?
if let path = Bundle.main.path(forResource: "yourFileName", ofType: "plist"){
myMenuArray = NSArray(contentsOfFile: path)
}
If you are working with Dictionary use below lines of code:
var myDict : NSDictionary?
if let path = Bundle.main.path(forResource: "yourFileName", ofType: "plist"){
myDict = NSDictionary(contentsOfFile: path)
}
Thanks
0 Comment(s)