mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-27 10:34:36 +01:00
19 lines
463 B
Swift
19 lines
463 B
Swift
|
//
|
||
|
// UserDefaultsExtension.swift
|
||
|
// BlueWallet
|
||
|
//
|
||
|
// Created by Marcos Rodriguez on 2/8/21.
|
||
|
// Copyright © 2021 BlueWallet. All rights reserved.
|
||
|
//
|
||
|
|
||
|
import Foundation
|
||
|
|
||
|
extension UserDefaults {
|
||
|
|
||
|
func codable<Element: Codable>(forKey key: String) -> Element? {
|
||
|
guard let data = UserDefaults.standard.data(forKey: key) else { return nil }
|
||
|
let element = try? PropertyListDecoder().decode(Element.self, from: data)
|
||
|
return element
|
||
|
}
|
||
|
}
|