LeadKit/TIKeychainUtils
Ivan Smolin 33cc31b957 docs: update podspecs and changelog 2023-05-31 18:19:43 +03:00
..
Sources feat: add AsyncSingleValueStorage for TINetworkingCache 2023-05-31 17:33:22 +03:00
TIKeychainUtils.app build: podspec and misc fixes 2023-05-29 12:27:59 +03:00
PlaygroundPodfile feat: add TIKeychainUtils playground with SingleValueStorage examples 2023-05-24 15:50:59 +03:00
README.md feat: Fix pr issue 2021-04-30 13:18:27 +03:00
TIKeychainUtils.playground feat: add TIKeychainUtils playground with SingleValueStorage examples 2023-05-24 15:50:59 +03:00
TIKeychainUtils.podspec docs: update podspecs and changelog 2023-05-31 18:19:43 +03:00

README.md

TIKeychainUtils

Set of helpers for Keychain classes. Bunch of CodableBackingStore from TIFoundationUtils and KeychainAccess. Implement

@propertyWrapper example

extension StorageKey {
    static var userProfileKey: StorageKey<UserProfile> {
        .init(rawValue: "userProfileKey")
    }
}

extension Bundle {
    var bundleId: String {
        Bundle.main.bundleIdentifier ?? .empty
    }
}

extension Keychain {
    static var defaultKeychain: Keychain {
        .init(service: Bundle.main.bundleId)
    }
}

final class ViewModel {
    @KeychainCodableBackingStore(key: .userProfileKey, codableKeyValueStorage: .defaultKeychain)

    private(set) var profile: UserProfile?
    
    func updateProfile(newProfile: UserProfile?) {
        profile = newProfile
    }
}