Fetch the repository succeeded.
方便地在 Swift 中利用 Objective-C 关联对象。
使用 Swift Package Manager 或手工导入。
You can also use GitHub source.
定义扩展属性可以像下面这样,不仅支持 Objective-C 对象,各种 Swift 类型也支持。
import B9AssociatedObject
private let fooAssociation = AssociatedObject<String>()
extension SomeObject {
var foo: String? {
get { fooAssociation[self] }
set { fooAssociation[self] = newValue }
}
}
Sign in to post a comment
Repository Comments ( 0 )