Plist sort by name in Xcode?

Is there a way to sort plist in Xcode by name?

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Alpha</key> <string>This is the letter alpha</string> <key>Beta</key> <string>This is the letter beta</string> 

etc...

I got this plist, but xcode refuses to display the plist in order ....

any ideas?

+4
source share
1 answer

The problem is not the plist, but the data structure that you are trying to place inside it. Dictionaries (in this context <dict> ) store information regarding a key meaning, in which there is no concept of order.

If you want to save objects of any type in any particular order, you must save the NSArray object to plist instead of NSDictionary. Arrays have the concept of order, because they store items at a numerical index representing the order of items in the array.

0
source

Source: https://habr.com/ru/post/1498658/


All Articles