Enumerations
The following enumerations are available globally.
-
Encapsulates a
[String:T]
dictionary whose values are automatically persisted (each in its own file).Exposes methods and properties similar to those of the Swift Dictionary.
Usage examples:
Create a
FileBackedDictionary
instance, using Documents subdirectory namedResources
andstruct Resource
as the value type.let directoryName = "Resources" var fbDict = FileBackedDictionary<Resource>(directoryName: directoryName)
Add resource instances
fbDict["apples"] = Resource(name: "apples", value: 1, quantity: 1) fbDict["oranges"] = Resource(name: "oranges", value: 2, quantity: 2) fbDict["mangos"] = Resource(name: "mangos", value: 3, quantity: 3)
Look up the resource info
let count = bDict.count // 3 let keys = fbDict.keys // ["apples", "oranges", "mangos"]) let values = fbDict.values // ... let myOranges = fbDict["oranges"]
Remove resources
fbDict["oranges"] = nil fbDict.removeAll()
At its initialization (typically at the application start), an instance of
See moreFileBackedDictionary
recovers the keys and values from the file storage.Declaration
Swift
enum FileBackedDictionaryError : Error