-
-
Save fitomad/f70ca3818b08fa48d8d8c021031924d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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