Skip to content

Commit 2953b58

Browse files
committed
UserDefaults+Woo: New Subscript Method
1 parent 1e93408 commit 2953b58

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

WooCommerce/Classes/Extensions/UserDefaults+Woo.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,15 @@ extension UserDefaults {
4444
set(newValue, forKey: key.rawValue)
4545
}
4646
}
47+
48+
/// Subscript: "Type Inference Fallback". To be used whenever the type cannot be automatically inferred!
49+
///
50+
subscript(key: Key) -> Any? {
51+
get {
52+
return value(forKey: key.rawValue)
53+
}
54+
set {
55+
set(newValue, forKey: key.rawValue)
56+
}
57+
}
4758
}

0 commit comments

Comments
 (0)