Skip to content

Instantly share code, notes, and snippets.

@onmyway133
Created June 15, 2018 08:37
Show Gist options
  • Save onmyway133/d7f5e70c0fd95f7f3eefd3f177d1d2bc to your computer and use it in GitHub Desktop.
Save onmyway133/d7f5e70c0fd95f7f3eefd3f177d1d2bc to your computer and use it in GitHub Desktop.
// Save to storage
try? storage.setObject(10, forKey: "score")
try? storage.setObject("Oslo", forKey: "my favorite city", expiry: .never)
// Load
let score = try? storage.object(ofType: Int.self, forKey: "score")
let favoriteCharacter = try? storage.object(ofType: String.self, forKey: "my favorite city")
// Check if an object exists
let hasFavoriteCharacter = try? storage.existsObject(ofType: String.self, forKey: "my favorite city")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment