Skip to content

Instantly share code, notes, and snippets.

View VaslD's full-sized avatar

Yi Ding VaslD

  • Shandong, China
View GitHub Profile
@VaslD
VaslD / CountingTimer.swift
Created December 14, 2022 18:31
基于 DispatchSource 的正计时器。
import Foundation
/// 递增(正)计时器,基于 `DispatchSource` 和 `CLOCK_MONOTONIC_RAW`,必须在主线程使用。
@MainActor
public class CountingTimer {
/// 计时原点:创建时刻或上次重置时刻。此数值为系统底层时钟周期,只能通过多次获取后计算时长(单位:纳秒)而不能用于确定当前日期时间。
public private(set) var origin: UInt64
/// 回调间隔。修改间隔时间将以当前时刻重新计算间隔,而非顺延上次回调后已经经过的时间。
public var interval: TimeInterval {
@VaslD
VaslD / OldStylePropertyList.swift
Created October 10, 2022 17:44
Working with old style (ASCII) plists in Swift...
import Foundation
import TabularData
/// OpenStep 格式 Property List 工具集。
///
/// OpenStep 格式 Property List 也称 ASCII Property List 或旧版 Property List。
public enum OldStylePropertyList {
// MARK: Property List
/// 将 `String` (`NSString`) 转为 OpenStep Property List 输出格式。