Skip to content

KeyStorage Save Options

Ben Bahrenburg edited this page Dec 31, 2016 · 2 revisions

#KeyStorage - Save Options

The below details the KeyStorage options available to save key values using one of the keyStorage providers.

##Write Options

setString - Saves String value to the provided key

keyStoreProvider.setString(forKey: "your-key", value: "hello")

setInt - Saves Integer value to the provided key

keyStoreProvider.setInt(forKey: "your-key", value: 1)

setBool - Saves Boolean value to the provided key

keyStoreProvider.setBool(forKey: "your-key", value: true)

setDate - Saves Date value to the provided key

keyStoreProvider.setDate(forKey: "your-key", value: Date())

setDouble - Saves Double value to the provided key

keyStoreProvider.setDouble(forKey: "your-key", value: 1.234)

setFloat - Saves Float value to the provided key

keyStoreProvider.setFloat(forKey: "your-key", value: 1.234)

setURL - Saves URL value to the provided key

keyStoreProvider.setURL(forKey: "your-key", value: URL(string: "http://bencoding.com")!)

setArray - Saves an NSArray value to the provided key

let array = [1,2,3,4]
keyStoreProvider.setArray(forKey: "your-key", value: array as NSArray)

setDictionary - Saves NSDictionary value to the provided key

let dict = [
    "a" : ["fname": "abc", "lname": "def"]
    ,   "b" : ["fname": "ghi", "lname": "jkl"]
]
keyStoreProvider.setDictionary(forKey: "your-key", value: dict as NSDictionary)

Clone this wiki locally