TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Aug 2016 |
SPMSupports SPM | ✗ |
Maintained by zhangzichen.
Pontus 是我使用 Swift 开发 iOS 应用一年下来所积累的一个工具库(当然其中深得之前共事同事的长处),这篇文章中我会简单说明一下自己是如何设计并使用 Pontus 的。
Pontus 的名字取自希腊神话名,比较喜欢他的蕴意:深不可测的大海,所以就叫这个名字了。
·Pontus使用Swift编写,仅支持iOS平台
·可以使用CocoaPods将Pontus集成进自己的项目(PS:pod search Pontus)
Pontus中很多方法都是为了实现链式语法,或者带有链式语法的特性
非链式语法:
object.propertyA = valueA
object.propertyB = valueB
object.propertyC = valueC
object.propertyD = valueD
链式语法:
object
.propertyA(valueA)
.propertyB(valueB)
.propertyC(valueC)
.propertyD(valueD)
我这样作的主要原因有:
·不喜欢在设置 object 的若干属性时每次都要多写一个 object
·可以在 map 等函数中设置属性的同时返回结果
这种方法基本实现:
extension Class {
// Chainable method of property
func property(property: propertyType) -> Self {
self.property = property
return self
}
}
My own iOS development kit, written by Swift.