mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 09:50:15 +01:00
19 lines
533 B
Swift
19 lines
533 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 userDefaults = UserDefaults(suiteName: UserDefaultsGroupKey.GroupName.rawValue), let data = userDefaults.data(forKey: key) else { return nil }
|
|
let element = try? PropertyListDecoder().decode(Element.self, from: data)
|
|
return element
|
|
}
|
|
}
|