FileStorage

public final class FileStorage<T> where T : Decodable, T : Encodable

FileStorage allow to store data

Important

This is a Public Preview API. It may be changed or removed at any time.

Public

  • Static method to cache a file.

    Declaration

    Swift

    public class func cache(fileName: String) -> FileStorage

    Parameters

    fileName

    File name where it will be stored.

    Return Value

    FileStorage object.

  • Static method to persist a file.

    Declaration

    Swift

    public class func persist(fileName: String) -> FileStorage

    Parameters

    fileName

    File name where it will be stored.

    Return Value

    FileStorage object.

  • Method used to save the current state of a class.

    Declaration

    Swift

    @discardableResult
    public func save(data: T) -> FileStorageError?

    Parameters

    data

    Generic type implementing the Codable protocol.

    Return Value

    If saving is successful, the returned value will be nil. If saving fails, the function will return a FileStorageError.

  • Method used to load the last state of a saved class.

    Declaration

    Swift

    public func loadData() -> (Result<T, FileStorageError>)

    Return Value

    If loading is successful load, the returned value will be the data. If loading fails, the function will return a FileStorageError.

  • Method used to clear the storaged data.

    Declaration

    Swift

    public func clear()