Pontus 0.0.3

Pontus 0.0.3

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2016年8月
SPM支持 SPM

zhangzichen 维护。



Pontus 0.0.3

  • 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
            }
        }

Pontus

我自己写的 iOS 开发工具包,用 Swift 编写。