Cent is an open source library from Ankur Patel providing helpers extending the features of many Swift data types.
Cent provides helpers for the Array, Date, Dictionary, Int, String and Range data types.
These snippets from the readme demonstrate the included at, each, and fetch commands:
let some = array.at(1, 3)
=> ["spam", "eggs"]
let array = ["foo", "spam", "bar", "eggs"]
array.each {
print($0)
}
=> ["foo", "spam", "bar", "eggs"]
let arr = [1, 2, 3, 4, 5, 6, 7, 8]
arr.fetch(100)
=> nil
arr.fetch(100, orElse: 42)
=> 42
arr.fetch(-1)
=> 8
You can find Cent on Github here.
A handy library for working with Swift data types.
Original article: Cent – Swift Library That Simplifies Working With Common Data Types
©2016 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.