Skip to content

trochoid/EZFile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

EZFile

This is a simple class that wraps the process of saving or loading a struct or class into a single file in the documents sandbox.

To use...

struct MyStruct : Codable { ... }  //mark your struct or class as Codable

let a = MyStruct()

EZFile.storeObject(a)   //write object to file

if let b = EZFile.retrieveObject(MyStruct.self) {   //attempt to read object from file  
    //Success! Now use b  
} else {  
    //failed :(  
}  

Operation...

Data is read and written to a single file in the users documents directory. Edit var filename to specify the file name.

To store an object a JSONEncoder is used to convert your Codable object into a Data object, then the Data can be written to a file. To load an object it does the reverse.

/*

some test

and more

code?

and close */

after

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages