LocalFileStorable

public protocol LocalFileStorable

an object that can be represented and stored as a local file

  • specifies the data structure that will be stored

    Declaration

    Swift

    associatedtype Element : Reflectable, Comparable, Decodable, Encodable, Hashable, Identifiable
  • defines the data that will be stored

    Declaration

    Swift

    var wrappedValue: [Element] { get set }
  • defines a String that characterizes the unique attributes of the wrappedValue

    Declaration

    Swift

    var storagePath: String { get }

Extension: LocalFileStorable: URL

  • localStorageURL Extension method

    URL of the parent folder to store the variable in

    Declaration

    Swift

    public var localStorageURL: URL { get }

Extension: LocalFileStorable: Load & Save

  • loadFromFile() Extension method

    Load an array of LocalFileStorables from a file

    Declaration

    Swift

    public func loadFromFile() -> [Element]

    Return Value

    an array of decoded objects

  • saveToFile(_:) Extension method

    Save a collection of LocalFileStorables to a file

    Declaration

    Swift

    public func saveToFile(_ collection: [Element])

    Parameters

    collection

    Collection of objects that should be saved