Skip to content

Instantly share code, notes, and snippets.

@onmyway133
Created June 15, 2018 08:08
Show Gist options
  • Save onmyway133/57681f8261e84314f625afb9b6abe7e0 to your computer and use it in GitHub Desktop.
Save onmyway133/57681f8261e84314f625afb9b6abe7e0 to your computer and use it in GitHub Desktop.
let cache = SpecializedCache<JSON>(name: "JSONCache")
// Dictionary
cache.async.addObject(JSON.dictionary(["key": "value"]), forKey: "dictionary")
cache.async.object(forKey: "dictionary") { json in
print(json?.object)
}
// Array
cache.async.addObject(JSON.array([["key1": "value1"]]), forKey: "array")
cache.object("array") { json in
print(json?.object)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment