CollectiveSwift 2.1.0

CollectiveSwift 2.1.0

Greg Pape 维护。



  • By
  • Greg Pape

CollectiveSwift

这是一个为 Swift 中UIKit实际开发提供的质量生活改进。

我经常发现自己需要写,例如。

someViews.forEach {
    $0.tintColor = someColor
}

CollectiveSwift 提供了等效的功能

someViews.all.tintColor = someColor

这与故事板中的 outlet 集合结合得很好。

包含了一些常用属性的扩展,但很容易添加自己的扩展。例如

extension Collective where Element: MyObject {

    var someProperty: Bool {
        get { Collective.gettersAreNotSupportedFailure() }
        set { base.forEach { $0.someProperty = newValue } }
    }

}

许可证

MIT