It’s not always safe to access a Binding within a callback that isn’t part of SwiftUI’s event system.
An example is illustrated in the following sample code:
extension Notification.Name {
static let event = Notification.Name("event")
}| // | |
| // RunOnMainRunLoopExitScheduler.swift | |
| // RunOnMainRunLoopExitScheduler | |
| // | |
| // Created by Yoshimasa Niwa on 11/5/25. | |
| // | |
| import Combine | |
| import Foundation |
| # Copy files to the "documents" folder by using MTP. | |
| # Mostly for sending documents locally to recent Kindle devices. | |
| # | |
| # Usage: python3 copy_to_documents.py [file ...] | |
| # | |
| # Requires `aftl` package that can be installed from a non-master branch at | |
| # <https://github.com/niw/android-file-transfer-linux>. | |
| # | |
| # Copyright (c) 2025 Yoshimasa Niwa | |
| # |
| // | |
| // Tuple.swift | |
| // Tuple | |
| // | |
| // Created by Yoshimasa Niwa on 8/8/25. | |
| // | |
| public struct Tuple<each T: Equatable>: Equatable { | |
| public static func == (lhs: Tuple<repeat each T>, rhs: Tuple<repeat each T>) -> Bool { | |
| var result = true |
| #!/bin/bash | |
| # Congratulations! You found the easter egg! ❤️ | |
| # おめでとうございます!隠されたサプライズを見つけました!❤️ | |
| # Define the text to animate | |
| text="♥PEACE♥FOR♥ALL♥PEACE♥FOR♥ALL♥PEACE♥FOR♥ALL♥PEACE♥FOR♥ALL♥PEACE♥FOR♥ALL♥" | |
| # Get terminal dimensions | |
| cols=$(tput cols) |
| // | |
| // UUIDv7.swift | |
| // UUIDv7 | |
| // | |
| // Created by Yoshimasa Niwa on 7/25/25. | |
| // | |
| import Foundation | |
| import Security |
| import Foundation | |
| public enum ChunkedDataTaskError: Swift.Error { | |
| case notSuccess(_ data: Data, _ httpResponse: HTTPURLResponse) | |
| } | |
| private extension Int { | |
| var isSuccess: Bool { | |
| (200 ..< 300).contains(self) |
| import AppKit | |
| import SwiftUI | |
| public struct TextView: NSViewRepresentable { | |
| @Binding | |
| var text: String | |
| var font: NSFont? | |
| public init( | |
| text: Binding<String> |
| import Foundation | |
| import Observation | |
| func onChange<Value>( | |
| of value: @autoclosure () -> Value, | |
| initial: Bool = false, | |
| perform: (_ oldValue: Value, _ newValue: Value) -> Void, | |
| _: isolated Actor = #isolation | |
| ) async throws { | |
| let (stream, continuation) = AsyncThrowingStream.makeStream(of: Void.self) |
| #!/usr/bin/env bash | |
| for i in {0..255}; do | |
| printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i" | |
| if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then | |
| printf "\n" | |
| fi | |
| done |