Latest 2.1.1
Homepage https://github.com/muukii/Unwrap
License MIT
Platforms ios 8.0, watchos 2.0
Dependencies OptionalProtocol
Authors

CI Status
Version
License
Platform
Carthage compatible

Syntax sugar for unwrapping while throwing error for nil

With this syntax sugar you can unwrap variables while throwing error for nil.
It’s useful in closures/functions with throw.

func unwrap<T: UnwrapProtocol>(object: T, _ error: ErrorType = default) throws -> T.Wrapped

Usage

let foo: Int = 3
let bar: Int? = 3
try unwrap(foo) // Compile error
try unwrap(bar) // OK

Advanced

{ [weak self] in
    let _self = try unwrap(self)
}
  • RxSwift
operation
    .doOnNext { [weak self] i
        let _self = try unwrap(self)
        _self.value = "abc"
    }    

Requirements

Installation

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

pod "Unwrap"

Author

muukii, [email protected]

License

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

Latest podspec

{
    "name": "Unwrap",
    "version": "2.1.1",
    "summary": "Syntax sugar for unwrapping while throwing error for nil",
    "description": "Syntax sugar for unwrapping while throwing error for nilnnWith this syntax sugar you can unwrap variables while throwing error for nil.nIt's useful in closures/functions with throw.",
    "homepage": "https://github.com/muukii/Unwrap",
    "license": "MIT",
    "authors": {
        "muukii": "[email protected]"
    },
    "source": {
        "git": "https://github.com/muukii/Unwrap.git",
        "tag": "2.1.1"
    },
    "social_media_url": "https://twitter.com/muukii0803",
    "platforms": {
        "ios": "8.0",
        "watchos": "2.0"
    },
    "source_files": "Unwrap/Classes/**/*",
    "dependencies": {
        "OptionalProtocol": []
    }
}

Pin It on Pinterest

Share This