Objective-C associated value wrapper for convenient use in Swift. It is primarily used to add attributes to existing types through extensions.
You can use either Swift Package Manager or manual importing to add this package to your project.
你也可以使用 gitee 镜像。
You can define extended properties like below. All kinds of Swift types are also supported, not only Objective-C objects.
import B9AssociatedObject
private let fooAssociation = AssociatedObject<String>()
extension SomeObject {
var foo: String? {
get { fooAssociation[self] }
set { fooAssociation[self] = newValue }
}
}