Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of plist?

Tags:

iphone

plist

In my application, I am using a plist. Please, can anyone explain what are the uses of plist with an example or a sample code?

like image 954
Pradeep Reddy Kypa Avatar asked Nov 18 '09 15:11

Pradeep Reddy Kypa


People also ask

What is Info plist used for?

The Info. plist file to store configuration data in a place where the system can easily access it. macOS and iOS use Info. plist files to determine what icon to display for a bundle, what document types an app supports, and many other behaviors that have an impact outside the bundle itself.

What does plist do on Mac?

Preference and configuration files in macOS use property lists (plists) to specify the attributes, or properties, of an app or process. An example is the preferences plist for the Finder in the Library/Preferences/ folder of a user's home folder. The file is named com. apple.

What's the Info plist file?

The Info. plist file contains critical information about the configuration of an iOS mobile app—such as iOS versions that are supported and device compatibility—which the operating system uses to interact with the app. This file is automatically created when the mobile app is compiled.

What is the use of plist in Swift?

plist file. This plist contains information about your iOS project. It's distributed as part of your app's binary package, and iOS uses it for example to display your app's name on an iPhone's home screen. See how there's a ton of information about your app in Info.


2 Answers

In the context of iPhone development, Property Lists are a key-value store that your application can use to save and retrieve persistent data.

All iPhone applications have at least one of these by default, the Information Property List:

The information property list is a file named Info.plist that is included with every iPhone application project created by Xcode. It is a property list whose key-value pairs specify essential runtime-configuration information for the application. The elements of the information property list are organized in a hierarchy in which each node is an entity such as an array, dictionary, string, or other scalar type.

like image 192
Ben S Avatar answered Oct 10 '22 22:10

Ben S


Plist are XML files in a specific format. Prior to XML, they had a custom format now called 'old plist'. (You almost never see that anymore save in legacy code.)

Foundations collection classes automatically generate XML files in the plist format when you use their serialization methods to write them to disk. They also automatically read them back. You can also write your own serializers for your own custom objects. This allows you to persistently store complex objects in a robust, human readable format.

One use for plist for programmers is that it is easier to use the plist editor to input and manage a lot of data than it is to try and code it. For example, if you have an class that requires setting a large number of ivars, you can create a plist, read it into an NSArray or NSDictionary and then initialize the instance by passing it the dictionary.

I use this technique when I have to use a large number of paths to draw complex objects. You define the path in the plist file instead of the code and edit the path in the plist editor.

It's also a handy way to create a large amount of detailed test data.

like image 33
TechZen Avatar answered Oct 10 '22 21:10

TechZen