Closed nixzhu closed 6 years ago
Hey @nixzhu thanks for your PR!
I don't think adding this extra step is necessary for the sake of simplicity when using Disk for most use cases.
In your case, where you want to change some of the JSONEncoder
's properties, like it's date coding strategy, I suggest you convert your Codable
struct to Data
first using your own JSONEncoder
and then using Disk to save that data, Disk.save(data, to: .documents, as: "messages.json")
But there is append
for Codable, in that case, data is not enough.
nixzhu's PR allows users to pass a custom decoder/encoder or use the default one. So merging it shouldn't cause any issue to existing code. It would be great if it could be merged, it would keep things nice and simple, rather than converting into a Data object back and forth.
I think we need to pass encoder & decoder if necessary. A pull request is here https://github.com/saoudrizwan/Disk/pull/16