IO services
File IO
Saving and Loading files
To load and or save any kind of file, use the respective SCDRuntime functions saveFile and loadFile:
func saveAndLoadData() {
let data = "CrossPlatformSwift rocks"
let fileName = "mystringdata.data"
let filePath = SCDRuntime.getSystem().path(forDocument: fileName)
SCDRuntime.saveFile(filePath, content:data)
let data2 = SCDRuntime.loadFile(filePath)
let eq = data == data2
print("worked = \(eq)")
}
Updated about 6 years ago