I have a dictionary (with Dictionary being ) which I'm trying to write in order of the keys into a plist. Writing without order is not too complicated:
do {
let data = try PropertyListSerialization.data(fromPropertyList: dic, format: PropertyListSerialization.PropertyListFormat.openStep, options: 0)
do {
try data.write(to: customPlistURL, options: .atomic)
print("Successfully write")
}catch (let err){
print(err.localizedDescription)
}
}catch (let err){
print(err.localizedDescription)
}
or using the Next Step equivalent.
But this writes the data as it is represented in the dictionary. I'm aware that the data itself is not in order within the dictionary so writing it in one go is probably not possible. So I guess the best way to achieve this is to extend the dictionary one by one. Or are there any other ways?
Of course I can write my own Tokenizer/Lexer/Parser to read the file after writing and ordering it then, but before I start that I want to make sure, this problem hasn't been solved.