saoudrizwan / Disk

Easily persist structs, images, and data on iOS
MIT License
3.1k stars 170 forks source link

Saving a String fails with error: "The data couldn’t be written because it isn’t in the correct format." #14

Closed hershalle closed 6 years ago

hershalle commented 6 years ago

I receive the error message when using this line:

Disk.save("testing", to: .temporary, as: "testing")

String is Codable so it should be supported, right?

saoudrizwan commented 6 years ago

A String isn't a valid type for JSONEncoder, the class Disk uses in the background. See http://benscheirman.com/2017/06/ultimate-guide-to-json-parsing-with-swift-4/ for more info.