Snippets

swift

Complete, checked snippets in this language.

swift

Wrap NSTextView for a plain-text SwiftUI editor

A complete SwiftUI wrapper around AppKit NSTextView with plain-text enforcement, word wrap, selection callbacks, and first-responder focus.

Type-checked and run with swiftc 6.4 on macOS 26, including clamped update-time selections, focus, and selection-change callbacks.

swift

Persist tab sessions without storing document text

A complete Swift session store that remembers tab metadata and selected tab while keeping document contents out of the session file.

Type-checked and run with swift 6.4 on macOS 26, including damaged JSON decode, negative selection clamping, and stale selected-tab repair.

swift

Write local recovery copies without autosaving over user files

A complete Swift recovery-copy service that writes atomic text and metadata files into a user-selected folder and cleans them up after save or discard.

Type-checked and run with swift 6.4 on macOS 26, including /tmp and /private/tmp folder aliases, no-follow reads, symlink rejection, cleanup, and tamper refusal.

swift

Open and save UTF-8 plain-text files safely

A complete Swift file service for .txt and .md documents with strict UTF-8 decoding, atomic saves, and a 10 MB warning.

Type-checked and run with swift 6.4 on macOS 26, including extensionless URL rejection and Save As filename traversal rejection.