Skip to content

Instantly share code, notes, and snippets.

@dmrev
dmrev / SmartKey.swift
Last active December 11, 2015 18:28
Another statically-typed NSUserDefaults inspired by https://github.com/radex/SwiftyUserDefaults
class SmartKeyBase: Equatable, Hashable {
private let defaults = NSUserDefaults.standardUserDefaults()
private(set) static var allKeys = Set<SmartKeyBase>()
let name: String
static func removeAllValues() {
allKeys.forEach { $0.removeValue() }
}
init(_ name: String) {