Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Threema/ThreemaFramework/Utilities/   (Social Medium ©)  Datei vom 26.9.2026 mit Größe 1 kB image not shown  

Quelle  UserSettingWrapper.swift   Sprache: JAVA

 

import Foundation
import SwiftUI

/// A property wrapper for user settings that provides both direct and bindable access.
@propertyWrapper
public struct UserSetting<Value> {
    private let keyPath: ReferenceWritableKeyPath<UserSettings, Value>
    private var shouldExit: Bool

    /// Initializes a new instance of the user setting property wrapper.
    /// - Parameters:
    ///   - keyPath: A key path to the specific setting in `UserSettings`.
    ///   - shouldExit: A Boolean value that determines whether the application should exit after setting the value.
    public init(_ keyPath: ReferenceWritableKeyPath<UserSettings, Value>, shouldExit: Bool = false) {
        self.keyPath = keyPath
        self.shouldExit = shouldExit
    }

    /// The current value of the user setting.
    public var wrappedValue: Value {
        get { UserSettings.shared()[keyPath: keyPath] }
        set { UserSettings.shared()[keyPath: keyPath] = newValue }
    }

    /// A bindable version of the user setting that can be used in SwiftUI.
    public var projectedValue: Binding<Value> {
        Binding(
            get: { UserSettings.shared()[keyPath: keyPath] },
            set: { UserSettings.shared()[keyPath: keyPath] = $0
                if shouldExit {
                    exit(1)
                }
            }
        )
    }
}

Messung
CHZG
829510092

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-11-04) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.