1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2024-12-08 06:42:04 +01:00
mastodon-app-ufficiale-ipho.../MastodonSDK/Sources/MastodonExtension/UserDefaults.swift
2021-07-19 20:16:56 +08:00

28 lines
587 B
Swift

//
// UserDefaults.swift
// Mastodon
//
// Created by MainasuK Cirno on 2021-4-26.
//
import Foundation
extension UserDefaults {
public subscript<T: RawRepresentable>(key: String) -> T? {
get {
if let rawValue = value(forKey: key) as? T.RawValue {
return T(rawValue: rawValue)
}
return nil
}
set { set(newValue?.rawValue, forKey: key) }
}
public subscript<T>(key: String) -> T? {
get { return value(forKey: key) as? T }
set { set(newValue, forKey: key) }
}
}