关联值 5.0.0

关联值 5.0.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新版本2019年3月
SPM支持 SPM

Brad HiltonBrad Hilton 维护。



关联值 5.0.0

  • Brad Hilton

关联值

关联值 允许你轻松地在类扩展中添加存储属性

extension UIView {
  var identifier: String {
      get {
          return getAssociatedValue(key: "identifier", object: self, initialValue: "Unknown")
      }
      set {
          set(associatedValue: newValue, key: "identifier", object: self)
      }
  }
}

享受!

安装

关联值 通过 CocoaPods 提供。要安装,只需在 Podfile 中添加以下行

use_frameworks!
pod 'AssociatedValues'

请确保在 .swift 文件顶部导入模块

import AssociatedValues

或者克隆此仓库或下载它作为 zip 文件,并将类包含到您的项目中

作者

Brad Hilton,[email protected]

许可证

AssociatedValues 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。