CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

OptionalTypes 1.0.4

OptionalTypes 1.0.4

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jun 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by HFCoreUI.



  • By
  • DragonCherry

OptionalTypes

Supports Swift primitive types to create a value from optional expression with default value.

Example

let nullable: Any? = nil
        
XCTAssertTrue(Int(nullable) == 0)
XCTAssertTrue(Int(nullable, defaultValue: 5) == 5)
XCTAssertTrue(Float(nullable) == 0)
XCTAssertTrue(Float(nullable, defaultValue: 5) == 5)
XCTAssertTrue(Double(nullable) == 0)
XCTAssertTrue(Double(nullable, defaultValue: 5) == 5)
XCTAssertTrue(CGFloat(nullable) == 0)
XCTAssertTrue(CGFloat(nullable, defaultValue: 5) == 5)
XCTAssertTrue(Bool(nullable) == false)
XCTAssertTrue(Bool(nullable, defaultValue: true) == true)

Installation

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

pod "OptionalTypes"

Unlicense

Do whatever you want with this code.