Latest 1.0.4
Homepage https://github.com/DragonCherry/OptionalTypes
License MIT
Platforms ios 8.0
Authors

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.

Latest podspec

{
    "name": "OptionalTypes",
    "version": "1.0.4",
    "summary": "Supports Swift primitive types to create a stable value from optional expression with default value.",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "https://github.com/DragonCherry/OptionalTypes",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "DragonCherry": "[email protected]"
    },
    "source": {
        "git": "https://github.com/DragonCherry/OptionalTypes.git",
        "tag": "1.0.4"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "OptionalTypes/Classes/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This