Last active
October 26, 2018 09:04
-
-
Save stremsdoerfer/220c075d11a678441ebad7e3a363c8ca to your computer and use it in GitHub Desktop.
This file contains hidden or 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
struct StandardPair<T> { | |
let key: String | |
var value: T? { | |
set { | |
if let safeValue = newValue { | |
UserDefaults.standard.set(safeValue, forKey: key) | |
} else { | |
UserDefaults.standard.removeObject(forKey: key) | |
} | |
} | |
get { | |
return UserDefaults.standard.object(forKey: key) as? T | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment