Skip to content

Instantly share code, notes, and snippets.

@Chronos2500
Chronos2500 / MarqueeLabel-Minimal.swift
Created May 13, 2025 15:19
MarqueeLabel Please be fully aware that these use Private APIs.
let label = UILabel()
label.text = "Swift is a modern, intuitive programming language crafted for all Apple platforms."
label.setValue(true, forKey: "marqueeEnabled")
label.setValue(true, forKey: "marqueeRunning")
label.setValue(0, forKey: "marqueeRepeatCount")
@macguru
macguru / ScopedTask.swift
Last active November 7, 2025 05:28
ScopedTask: A wrapper around Task that auto-cancels when going out of scope.
/// A task that is cancelled if goes out of scope, i.e. the last reference on it has been discarded.
public final class ScopedTask<Success: Sendable, Failure: Error>: Sendable {
/// The underlying task
let wrapped: Task<Success, Failure>
/// Wraps a task into a scoped task.
init(wrapping task: Task<Success, Failure>) {
wrapped = task
}