One Quickie


Adding a new environment value (SwiftUI->Random)
private struct ScreamAtMeKey: EnvironmentKey {
    static let defaultValue = false
}

// Set via .environent(\.screamAtMe, true)
extension EnvironmentValues {
    var screamAtMe: Bool {
        get { self[ScreamAtMeKey.self] }
        set { self[ScreamAtMeKey.self] = newValue }
    }
}

// Set via .screamAtMe(true)
extension View {
    func screamAtMe(_  aaaaaah: Bool) -> some View {
        environment(.screamAtMe, aaaaaah)
    }
}



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com