Skip to content

Instantly share code, notes, and snippets.

@fitomad fitomad/nscache_prueba.swift Secret
Created May 28, 2019

Embed
What would you like to do?
// Creamos la cache
let cache = QuotesCache()
if let citaData = "Esto es una prueba de NSCache".data(using: .utf8)
{
// Añadimos un valor
cache.add(citaData, forKey: "Me")
// Y lo recuperamos
if let resultado = cache["Me"], let cita = String(data: resultado, encoding: .utf8)
{
print(cita)
}
cache.removeItem(forKey: "Me")
// Y lo recuperamos
if let _ = cache["Me"]
{
print("No se ha borrado la entrada")
}
else
{
print("Ha desaparecido de la cache")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.