SwiftyCast

Codacy Badge License MIT CocoaPods Compatible Carthage Compatible Platform Linux Code Coverage

Swift Package Xcode Project Cocoapods Carthage

SwiftyCast 是一个轻量级框架,用于轻松地将对象转换为 iOS、macOS、tvOS 和 watchOS 的 UnsafeRawPointer 类型。

安装

SwiftyCast 可通过 CocoaPodsCarthageSwift Package Manager 安装。

要通过 CocoaPods 安装,只需将以下行添加到您的 Podfile

pod 'SwiftyCast'

要通过 Carthage 安装,只需将以下行添加到您的 Cartfile

github "SomeRandomiOSDev/SwiftyCast"

要通过 Swift Package Manager 安装,请将以下行添加到您的 Package.swift 文件的 dependencies

.package(url: "https://github.com/SomeRandomiOSDev/SwiftyCast.git", from: "1.0.0")

用法

首先在您的 Swift 文件的顶部导入 SwiftyCast

import SwiftyCast

导入后,使用方法就像调用四个函数之一一样简单

// For casting to or from a raw pointer
unsafeBridgingCast(_:) 

// For casting to a raw pointer while incrementing the retain count of the object
unsafeBridgingRetain(_:)

// For casting from a raw pointer while decrementing the retain count of the object
unsafeBridgingRelease(_:)

// For casting to or from a raw pointer but only in the context of a callback block
withUnsafeBridgingCast(_:body:)

贡献

如果您需要特定功能或遇到错误,请提出 issue。如果您自己扩展了 SwiftyCast 的功能,或者您想自己修复错误,请提交 pull request。

作者

Joe Newton, somerandomiosdev@gmail.com

许可证

SwiftyCast 根据 MIT 许可证提供。 有关更多信息,请参见 LICENSE 文件。