I am learning iOS. I have a confusion about the Plist file, about the creator, applicable platform, format and so on. So what the Plist file really is?
-
`man plist` or any public documents will tell you plist file has two formats, XML and binary. Actually, there is an old-style ASCII property list, and Xcode's project.pbxproj is of this kind. – DawnSong May 24 '19 at 13:10
2 Answers
PList is a property list. You can find more useful information at:
http://nscookbook.com/2013/02/ios-programming-recipe-13-using-property-lists-plists/
How to use pList in iOS Programming
And the following one would give you more infor about the specific keys:

- 1
- 1

- 2,909
- 1
- 23
- 27
-
1I agree with your answer. I want just to make a remark (for a newbie). `plist` is a file which contain KEY - VALUE. @Liu2er, you can use is to store objects inside it (mainly strings and numbers, but you can store also `NSData`). – Bogdan Bogdanov Aug 05 '15 at 09:34
-
2While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – LittleBobbyTables - Au Revoir Aug 05 '15 at 12:14
-
@LittleBobbyTables, I would agree if the question was more specific. Is far as I see it is phrased, saying "Plist is a property list" actually does answer the question. The rest of it is so generic that it's impossible to answer in a few words. Besides - those links include official reference sites, which are not only supposed to be highly available, but also updated. Duplicating their content would contribute the diffusion of out of date and inexact information. – Dmitri Sologoubenko Aug 05 '15 at 13:44
A plist file is a property list. You can either create it using the nice animations Xcode gives you, or you can create pragmatically using XML. A plist file is something that can store objects (string, bool, data, date, number), like a database. And you can run through the plist file to retrieve or store the information just like a database.
In games you mostly save your score using NSUserDefaults as the data isn't sensitive, however saving information like a home address in NSUserDefaults isn't the best idea. Instead you'd rather want to save the information in a database - a plist file. Apple uses plist files in their apps. When you open contacts the information is retrieved from the plist and then put into a UITableView. When you click on a person it gives you their details, the details which were received from the plist file.
Another great things about a plist file is that you can change it from binary to XML and vice versa. Why would you ever want to change it to binary? Sometimes when you're dealing with large data e.g. a whole dictionary, it'll be faster to run through the data is binary than it would be in XML. To change it into binary, you go to terminal and use this command, plutil -convert binary1 yourFile.plist
. To change binary to XML you use this command, plutil -convert xml1 yourFile.plist
.
A plist in raw XML looks like:
A plist with the nice animation in Xcode looks like:
And finally a plist in binary looks like:
Now lets say you've created your plist and stored all the information in it that you want. To retrieve this information (in objc) use the following code.
NSString *path;
path = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"plist"];
NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:path];
for (NSString *str in array) {
@autoreleasepool {
NSLog(@"%@", str);
}
}
Hope this helped you!!

- 357
- 3
- 13
-
-
Thank you for giving me this straightaway analysis. It really helped me! – Liu2er Aug 07 '15 at 14:18