有用的 Swift NSOperation 和 NSOperationQueue 子类

OTO业务

CI 构建状态 平台 - macOS |苹果 |电视操作系统 |手表操作系统 执照:麻省理工学院

有用的 Swift () 和 () 子类。NSOperationOperationNSOperationQueueOperationQueue

可扩展、线程安全且自动完全报告嵌套子操作的进度。

  • 基础
    • BasicOperationBasicAsyncOperation
  • 基于闭包
    • ClosureOperationAsyncClosureOperation
    • InteractiveClosureOperationInteractiveAsyncClosureOperation
  • 线程安全的原子可变性
    • AtomicBlockOperation

安装:Swift Package Manager (SPM)

应用程序中的依赖关系

  1. 使用 Swift Package Manager 将包添加到您的 Xcode 项目中
    • 选择“文件→ Swift 包→添加包依赖项”
    • 使用作为 URL 添加包。https://github.com/orchetect/OTOperations
  2. 根据需要将模块导入 *.swift 文件中。
    import OTOperations

Swift 包中的依赖关系

  1. 在包.swift文件中:

    dependencies: [
        .package(url: "https://github.com/orchetect/OTOperations", from: "1.0.0")
    ],
  2. @_implementationOnly防止将 中的方法和属性导出到 SPM 包的使用者。OTOperations

    @_implementationOnly import OTOperations

文档

Most methods are implemented as category methods so they are generally discoverable.

All methods have inline help explaining their purpose and basic usage examples.

Author

Coded by a bunch of 🐹 hamsters in a trenchcoat that calls itself @orchetect.

License

Licensed under the MIT license. See LICENSE for details.

Contributions

Bug fixes and improvements are welcome. Please open an issue to discuss prior to submitting PRs.

GitHub

点击跳转