SJSwiftExtensions 0.1.2

SJSwiftExtensions 0.1.2

Maintained by Dmytro Cheverda.



SJSwiftExtensions

Swift 4.0 CI Status Version License Platform

Installation

SJSwiftExtensions is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SJSwiftExtensions'

Usage

Bool

let boolValue = true
boolValue.toggle = false
let trueValue = true
let falseValue = false
trueValue.stringValue   /// "true"
falseValue.stringValue   /// "false"

Collections

var array: [Int] = []
array.isNotEmpty   /// false
array.append(2)
array.isNotEmpty   /// true

String

let emptyString = ""
emptyString.isNotEmpty   // false
let someString = "fooBar"
someString.isNotEmpty   // true

UIColor

let turquoise = UIColor(colorWithHexValue: 0x2FD3C7)
turquoise.darker(by: 10.0)   // darkens color by 10 percents
turquoise.lighter(by: 10.0)   // lightens color by 10 percents

UIViewController

Controller identifier, can be used to load ViewController from storyboard by ID

let viewController = SomeBasicViewController
viewController.identifier   // "SomeBasicViewController"

UITableView

Register cell for identifier same as cell class name:

tableView.register(CustomTableViewCell.self)

Cell dequeue without stating explicit identifier:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tv.dequeueReusableCell(forIndexPath: indexPath) as CustomTableViewCell
    return cell
}

UITableViewCell

let cell = CustomTableViewCell
cell.identifier   // "CustomTableViewCell"

Author

[email protected]

License

SJSwiftExtensions is available under the MIT license. See the LICENSE file for more info.