I thought XML is better than Plist
XML is easy to edit, and makes data simple.
Well, though XML can describe properties in attributes but it also has some limits. And without the editor it seems NOT THAT easy to edit. 😂
-
XML limits the attribute name convention (should starts with letter or underscore then follows letters, digits, hyphens, underscores, and periods) which will breaks some custom initial-key features:
-
!for events, like!click,!change -
@for tagged or alias views, like@title.text,@1.value.
-
-
Plist is well supported by official:
- Xcode Plist editor support
- Copy/Paste line(properties)
- [Drag] to move line(properties)
- [Enter] to append a new line(properties)
- [Tab] to next
- Compress/Decompress support
- With the
plutilCLI, we can convert a plist to binary, xml format. futher more, the IDE can correctly display the Property List View from the binary and allow you to edit it directly.
- With the
- Xcode Plist editor support
-
XML attribute value accepts string only which is hard to describe nested properties (dictionary or array).
As example, we wanna to describe following properties:
- properties (dict) - backgroundColor = "#f0f0f0" - clients (array) - item0 (dict) - clazz = "GithubClient" - action = "/repos"in XML way:
<PBTableView backgroundColor="#f0f0f0"> <clients> <item clazz="GithubClient" action="/repos"/> </clients> </PBTableView>As we see, the backgroundColor and clients are in the same level, but we had to create a new node("deeper level") for clients cause it's value is an array. This may also brings the naming convention discussions, should we use:
-
<item clazz="GithubClient" ..., -
<client clazz="GithubClient" ...or directly -
<GithubClient action="/repos" ...
-
-
Plist performance is as well as XML. I just test the non-nested properties in BMParsingTests.m:
- Plist, [0.001082, 0.001064, 0.000677, 0.000727, 0.000605, 0.000624, 0.000605, 0.000528, 0.000558, 0.000560]
- XML, [0.001572, 0.001078, 0.000891, 0.000650, 0.000642, 0.000624, 0.000595, 0.000624, 0.000571, 0.000511]
The nested data struct is hard to test cause we should implement a customized
XMLParserfor each XML.
Totally, we use Plist as the configuration file cause:
- Simple to edit
- Easy to view
- Less convention
- More customizable